I have a Linux machine that cannot access the internet and I need to install the Jupyter notebook on it, without root privileges. I can copy whatever files to my machine and them copy those files to the remote machine. How can I get all dependencies and install them, without using Anaconda, for example? Pip is ok.
问题:
回答1:
warning: this answer might fail in future due to a possible deprecation in --relocatable
option in virtualenv
idea: create a relocatable virtualenv in another computer, install jupyter in there, and tar and move it to the said linux machine, untar it, and profit
Nb. To install virtualenv, run pip install virtualenv
step 1: create a virtualenv
$ virtualenv .venv
step 2: activate .venv
$ . .venv/bin/activate
step 3: install jupyter
$ pip install jupyter
step 4: mark .venv as relocatable
$ virtualenv --relocatable .venv
step 5: tar the .venv directory
$ tar czfv venv.tgz .venv/
step 6: move to offline linux machine, and untar
$ tar xvzf venv.tgz
step 7: activate virtualenv to use it
$ . .venv/bin/activate
回答2:
If anyone still gets the following error:
-bash: ./.venv/bin/jupyter-notebook: /home/hhoward/.venv/bin/python2.7: bad interpreter: No such file or directory
(To add to Ayush's answer)
It is important to run the relocatable command AFTER the jupyter installation.
pip install jupyter
virtualenv --relocatable .venv
Hope this helps.
回答3:
You can use another Linux machine with internet access to create an installation file and then move it to your machine and install it.
- On internet access machine create
tar.gz
file of jupyter's installation files:
mkdir jupyter
cd jupyter
pip download jupyter
cd ..
tar -czvf jupyter.tar.gz /jupyter
Move the created
jupyter.tar.gz
file to your machine using external hard drive.On your machine install the
jupyter.tar.gz
file:
tar -zxvf jupyter.tar.gz
cd jupyter
ls *.gz | xargs -n1 tar -xzf
ls *.zip | xargs -n1 unzip
for D in */; do pip install -e $D --no-index; done
pip install *.whl --no-index
- Check that everything work well with:
jupyter notebook --ip 0.0.0.0 --port 9999 --allow-root
** If you wanna use Jupyterlab instead Jupyter-notebook replace this two lines:
a. replace pip download jupyter
with pip download jupyterlab
.
b. replace jupyter notebook --ip 0.0.0.0 --port 9999 --allow-root
with jupyter lab --ip 0.0.0.0 --port 9999 --allow-root
.