I have a Unix server where I have Python3 installed. I ssh to the server from my mac.
I was wondering if it possible to install Anaconda and Jupyter (will come with Anaconda) on the server so that I can just pull up Jupyter on the server terminal and run codes on jupyter running on the server.
Is it possible? And if yes, could someone guide me to the right link?
in a terminal on your remote server:
#download anaconda (change version if you want)
wget https://repo.continuum.io/archive/Anaconda3-2018.12-Linux-x86_64.sh
# run the installer
bash Anaconda3-5.1.0-Linux-x86-64.sh
# so changes in your path take place in you current session:
source ~/.bashrc
#To run a remote notebook, replace XXXX with your choice of four numbers like 9191
jupyter notebook --no-browser --port=XXXX
#copy the url that you get as a result
Then in your local machine, open up a terminal and write:
#XXXX is the port you specified in the previous step, YYYY is a local port, for example 9999 to keep it simple
ssh -f [USER]#[SERVER] -L YYYY:localhost:XXXX -N
Then copy the url from the previous step, paste it in a browser, since you used the same port, you don't have to change anything on the url
you can download anaconda using:wget https://repo.continuum.io/archive/Anaconda3-5.1.0-Linux-x86_64.sh
and install using: bash Anaconda3-5.1.0-Linux-x86_64.sh
After that just source the path of Anaconda in .bashrc file, it should work.
To access jupyter notebook, you can use ssh and run notebook in your browser on your host. Steps are mentioned in this link
Yes you can install anaconda on your linux machine (Server) and manage the python environment. But if just need Jupyter hosted in a server, just install Jupyter only and start the service which will server Jupyter Notebook. Access Jupyter notebook using your browser on any other PC.
Make a google search that how to install anaconda on Linux machine (Centos/Ubuntu etc)
After installation run following command
conda info
and then configure the Jupyter and run.
Simple way (Install Jupyter on a server): Install, Run, and Connect to Jupyter Notebook on a Remote Server
Related
I would like to activate the venv. I'am using the remote interpreter because pycharm has got the connection via SSH with GCP VM. I used to activate env by using this command:
On Unix or MacOS, using the bash shell: source /path/to/venv/bin/activate
In local mode there is no tackle with it but for remote interpreter I do not know how to find the source. Could you please help me with this tackle?
I am having trouble with my vscode and ssh connection.
I have installed miniconda on my local machine at home/sam/miniconda3, and I have installed anaconda on a remote HPC machine on home/sam/anaconda3.
I have replicated conda envirenments in both using a yml file. Recently, the I keep getting errors while connecting to ssh that "python was not found". After digging for a while, I realize that when running a jupter nb, it looks for python under the local machine path (home/sam/miniconda3). Despite the case that I have selected the kernel from the remote machine path (/home/sam/anaconda3/envs/myenv/bin/python3.9).
How can I get the notebook in vscode to look at the remote path when connected to the remote machine?
Thanks heaps!
I recently updated jupter_over_ws to version 0.0.7 and now Google Colab refuses to connect my local runtime.
I have tried multiple iterations of launching the localhost in chrome, running with --no-browser etc and keep receiving a 'Forbidden' 403.
The last iteration I got to in an attempt to connect to the notebook was:
jupyter notebook --NotebookApp.allow_origin='https://colab.research.google.com' --NotebookApp.port_retries=0 --notebook-dir="" --no-browser --allow-root --NotebookApp.token='' --NotebookApp.disable_check_xsrf=True --port=8888
Any help much appreciated
Colab recently updated it's local runtime connection instructions.
In particular, you'll need to provide the URL printed in the console when starting the local runtime.
Clicking the "More Details" button in the local connection dialog will provide additional instructions.
After update, you need first upgrade jupyter_http_over_ws:
pip install --upgrade jupyter_http_over_ws
And second, everytime you start the server with this code:
jupyter notebook --NotebookApp.allow_origin='https://colab.research.google.com' --port=8888 --NotebookApp.port_retries=0
It will show a new token in Anaconda's prompt, you need to copy.
When you click in Connect to local runtime in Colab, a box will ask for the token, then paste there.
I solved this by removing the password from the jupyter .config file, then copy and pasting the token url as you have outlined in the answers above, and as outlined in the official colab documentation:
https://research.google.com/colaboratory/local-runtimes.html
If you use Anaconda, you can follow the instructions:
Open cmd.exe as Administrator
Run pip install --upgrade jupyter_http_over_ws>=0.0.7 && jupyter serverextension enable --py jupyter_http_over_ws
Run jupyter notebook --NotebookApp.allow_origin='https://colab.research.google.com' --port=8892 --NotebookApp.port_retries=0
Copy the URL from the command prompt printed console ex: http://localhost:8892/?token=fecaca2501d00f89971ab8fb4a5add3ff682ade7e63f7265
Paste the URL including token in Google Colab connection settings as Backend URL
In my local machine with macOS Mojave, I installed a virtual environment with Python 3.6, opencv package and some additional unrelated packages.
I started a very simple Jupyter Notebook that is executed with no problem, here it's the code:
import cv2
print(cv2.__version__)
my_img = cv2.imread("colibri_763_460.jpeg",1)
cv2.imshow("Original", my_img)
cv2.waitKey(0)
cv2.destroyAllWindows()
Now, I'm trying to execute the same code in a Jupyter Notebook in my remote Ubuntu machine but I can't make it work. These are the steps that I took:
I copied the image file and the Notebook ypnb file to the remote ubuntu machine.
I opened an ssh session, selected a virtualenv with the same packages than my local machine and executed the "jupyter notebook"
I opened another terminal with ssh -L 8000:localhost:8888 mpastorg#mpgubu18 for the ssh tunneling
I opened my local browser in the localhost:8000 to execute the Notebooks that I have in my remote Ubuntu machine, it works with any Notebook not involving opencv.
I tried to solve my problem using two different ways:
Installing in the ubuntu remote machine the package opencv-contrib-python-headless: when I try to use cv2.imshow, I got the error method not found
Installing in the ubuntu remote machine the package opencv-contrib-python: I got the error that kernel is dead.
Does anyone know if there's any way to execute the remote jupyter notebook and see the picture locally? it maybe would be possible a workaround to embed the picture in the browser window?
Thank you very much
Marcos Pastor
I wonder if the image is being rendered using X - which you have not explicitly enabled, in both your host machine, nor in your ssh tunnel.
On the Host machine. (Where you want to see the Image).
Enter this comment
xhost+
This now allows remote X-Hosts to send you data. As you are on a Mac - you will need to have the XQuartz package installed.
Now modify your ssh command. - so that you allow X - this is typically done using a -X flag (Or it can be placed in your .ssh/config file like this
Host *
ForwardX11 yes
ForwardX11Trusted no
XAuthLocation /opt/X11/bin/xauth
ForwardAgent yes
Compression yes
KeepAlive yes
Compression yes
If you are not using a config try the -X to start with.
Hope that helps
I have iPython running from a secured server on an Ubuntu server VM running on my laptop.
Command line ipython works on the server vm from the virtualenv. I can also start the notebook server on the server vm from the virtualenv without errors.
I can access notebooks from the host laptop and execute code in cells, but if I start the notebook server after activating a virtualenv I can't import any of the Python modules I've installed in the virtualenv.
It looks like the notebook server process is running the system Python but not the version in my virtualenv. Is there a way to tell the notebook server process which virtualenv to use?
Because virtualenv on activation adds its own ways to the begining of the PATH environment variable, you have two options:
a) create correct virtualenv on the notebook server and install everything from there
b) modify PYTHONPATH variable in order to get access to your libraries.