Remote Python Environment for Sublime - python

For various purposes one might need to hook up a remote python interpreter.
How can I access anaconda/bin from an sshfs mounted folder, all tries yielded access denied since the interpreter and python file are on different machines.
There is a solution of hosting a server on the remote machine to access the remote conda install, this is not an option.
Alternatively one could install the same environment locally, how would one keep them in sync?
The main idea is to get anaconda sublime functionality on the local machine. Running/managing a python project can easily be done through ssh.
Edit: I am aware of the various remote/on_server editing options, (vim, emacs ...) but we have to stick to sublime.
Note: I do not have sudo privileges on this server.

Related

PyCharm remote debug using remote container Python interpreter

My situation is that I have set up a container in a remote server, and inside the container, there is a virtual environment. I'm using the python interpreter inside this virtual environment in this container, not the one on the host.
From my local machine, I can open up PyCharm, and use Tools->Deployment->Configuration to easily set up a remote connection. And For a specific project, I can set up the interpreter by clicking Files->Settings->Project Interpreter. However, it seems that I can only select the host Python interpreter(/usr/bin/python) on the remote server, not the one inside the virtual environment in the container. How could I set up using this interpreter?
I googled but can't find exact solution. I don't think I need to install Docker locally because my Docker is on the remote server side, right?
In similar way you are connecting to remote host - you would need to setup container with same capabilities e.g. set ssh server running on there. Then you should expose the port into public world or use nested ssh tunnel, which would be better alternative.
Another interesting approach (maybe recommended) is to forward Docker socket from the remote machine so, that you local Docker CLI uses this socket for sending commands to remote host. Theoretically, then you could add this container directly in PyCharm, when you set correct Docker host address there.
Further, virtual environments on other than local host systems are not supported natively by PyCharm. However, you could try to add path of python and see if it works e.g. venv/bin/python from project directory.

How to set up full access to the shared folders in Linux?

everyone.
I run Linux python scripts under Linux virtual machine. There are a few shared folders between host and guest system. Script works with files in folder mounted to guest file system through VirtualBox Tools. I have changed access mode to all files and directories in this folder. Other programs (e.g. MatLab) have full access (create or delete any file) to shared file system if I run it under super user. Python returns this error when I run shutil.rmtree(path):
OSError: [Errno 26] Text file busy
How can I share my folders without the similar problems?
Details:
Guest - Linux Ubuntu 18.04
Host - Windows 10
VirtualBox version 6.1.6 r137129
Python 3.6
I get this problem as well with shared directories. To my knowledge, there is only one solution to this: don't work with executable files in shared directories.
My understanding of the problem is that the guest operating system is trying to run your command on that file/directory while the host operating system is currently doing something with it via VirtualBox. I don't know the specifics on what exactly VirtualBox is doing in this context, but I suspect it has something to do with synchronizing the content of the files back to the host.
Probably not the answer you were hoping for, but virtual machines are meant to be entirely self-contained, so using shared directories should probably be avoided. If your code is version controlled using something like Git, try cloning the repository into the virtual machine instead.

How to connect local PyCharm to python installed on a server? Is this even possible?

I have PyCharm on my machine (8GB RAM). I am required to to heavy data processing, and would like to use an institutionally provided server. This server has Python installed, but without any IDE. So all I see is a CUI, and it is difficult to program in such an environment.Also note that I cannot ask server admin to install software on the server for me. So, how can one connect one's local PyCharm to a python installed on a remote server? Is this even possible?
You can configure an interpreter using SSH:
Open the Add Python Interpreter dialogue
In the left-hand pane of the Add Python Interpreter dialogue, click SSH Interpreter.
Follow the wizard.
For more detailed instructions, check:
https://www.jetbrains.com/help/pycharm/configuring-remote-interpreters-via-ssh.html
Note: unfortunately, this option is not available in the PyCharm Community Edition.

Visual Studio Code use on remote files

Is there any way to use the python extension to edit files that reside on a remote server? I have tried NFS and remoteFS, but I do not see any way to get Intellisense working using the remote installation. I normally edit and test on a windows machine, while the target runs on Linux.
I realise this is not limited to this extension, but is a more general issue.
Visual Studio Code now officially supports this using an Extension: Remote SSH
Read the release notes here: https://code.visualstudio.com/blogs/2019/05/02/remote-development
Today we're excited to announce the preview of three new extensions for Visual Studio Code that enable seamless development in Containers, remotely on physical or virtual machines, and with the Windows Subsystem for Linux (WSL). You can get started right away by installing the Remote Development Extension Pack.
As a workaround, I'm using a Linux Hosted virtual machine which has a similar setup as the target. This works surprisingly well. It is a shame VMware 12 removed support for unity.
I use SSHFS (wikipedia) (github repo)
sshfs OWN_USER#SERVER:/PATH_TO_FILES/ MOUNT_POINT
This makes the remote files visible to any program on your computer, as-if they were local files, through a virtual "FUSE" filesystem.
If your own user can't access the files (you need root or some other user), you can sudo like so:
sshfs -o sftp_server="sudo -u SYSTEM_USER /usr/libexec/openssh/sftp-server" \
OWN_USER#SERVER:/PATH_TO_FILES/ MOUNT_POINT
You can install sshfs for Linux, Mac, or Windows, check out Digital Ocean's guide in my first link.
Don't forget to umount, fusermount -u, or eject that MOUNT_POINT once you're done.
I don't know if other VS Code plugins like IntelliSense would work with this. They should because the sshfs makes the files visible just like any others. But, it would require that the python tool chain you have installed locally be the same on your laptop and on the server. It'd be interesting to find out.
Or, Microsoft just announced some new plugins on the way
Yes there are some. I used this one. It allows to synchronize code between local and remote server.
You will have to keep copy on local host and it can be configured to automatically update code on remote.
https://gurumantra.themillennialpost.info/2020/05/edit-linux-files-remotely-in-vscode.html
Download and install vscode in your localPc if you don’t have it. (click here to download vscode)
Summary :
Install Vscode, remote vscode – LocalPC
Install ssh and Rmate – RemotePc
Ready to access files/data
Detailed Steps:
https://gurumantra.themillennialpost.info/2020/05/edit-linux-files-remotely-in-vscode.html

Is it possible to run pydev connected to a virtualbox instance?

At the moment I'm developing using a simple editor, putty, and a VirtualBox instance of a linux server. I've heard good things about pydev and would like to try it, but I'd like to use the python install & terminal from my VirtualBox guest OS.
I'm already using a Shared Folder with VirtualBox so my Guest OS can see my local files.
Is it possible to tell pydev to use this "remote" host over SSH to execute its python-related commands?
UPDATE:
My main environment is windows, but I'd also like to be able to work this way on OS X.
I assume your host box is windows.
I also assume that pydev will run under linux (since it's eclipse based). Are you ok installing the dev environment on your linux server?
In which case:
install and run xming on your windows box
Install eclipse & pydev on your linux box
Configure x forwarding in putty
Run pydev through putty and you'll have the UI appear on your windows machine like normal
Then pydev will be running on the linux box quite happily, and so using the python environment on there.
Downsides: you will need to install the X libraries & java on your server (installing eclipse using your normal package manager should be enough), although you won't need to run X itself, since that's what Xming is for.
UPDATE:
Let me understand the situation, Windows is hosting the virtualBox which host the linux.
You connect to the linux using putty.
Python files are on the linux machine and you wish to edit them from your Windows using pydev. So either do that using the sharing features of virtual box (which can work for you in vboth ways) or use ssh to edit the linux files from windows.
both options would be valid for MacOSx AFAIK
Below you cna find the way to do so over SSH
You map a netwrok drive over SSH and then you can access the files via that drive letter
see more at
http://www.neophob.com/serendipity/index.php?/archives/103-Map-a-Network-drive-net-use-over-SSH.html
and
http://smithii.com/map_a_network_drive_over_ssh_in_windows

Categories

Resources