安裝python 參考:https://blog.csdn.net/m0_37711292/article/details/131593577
1. 更新軟件列表
sudo apt-get update
2. 安裝pip
sudo apt-get install -y python3-pip
3. 更新pip
python3 -m pip install --upgrade pip
4. 使用pip安裝Jupyter
pip install jupyter notebook
5 添加環境變量
sudo vim /etc/profile
添加如下代碼
export PATH=$PATH:~/.local/bin
退出編輯
source /etc/profile//執行配置
6. 創建Jupyter默認配置文件(記住生成文件的位置,后面要用到)
jupyter notebook --generate-config
7. 生成SHA1加密的密鑰,保存密鑰,如'sha1:XXXXXX'
ipython
from notebook.auth import passwd
passwd()
Out[2]: 'sha1:7e07e7fe86be:f5b3b8f2b30a1b0f7586b0ddf08b8dd836a9bf00'
exit();
8 設置jupyter 文件
sudo vim /home/ubuntu/.jupyter/jupyter_notebook_config.py
添加下面的代碼
c.NotebookApp.allow_remote_access = True #允許遠程連接
c.NotebookApp.ip='0.0.0.0' # 設置所有ip皆可訪問
c.NotebookApp.password = 'argon2:$argon2id$v=19$m=10240,t=10,p=8$4EIqux1hNfgkFuqoWiEnUQ$k/CAr9P2J4/5GlBcsXTnJA' #之前復制的密碼
c.NotebookApp.open_browser = False # 禁止自動打開瀏覽器
c.NotebookApp.port =8888 #任意指定一個端口
c.NotebookApp.notebook_dir ='/home/ubuntu/programes/'
【若是使用python創建虛擬環境的話:
1、創建虛擬環境
python -m venv venv_test(虛擬環境名)
2、激活虛擬環境
source/venv_test/bin/activate
3、安裝內核
pip install ipykernel
4、配置內核到jupyter
python -m ipykernel install --user --name venv_test
】
9 啟動 jupyter notebook
nohup jupyter notebook --allow-root > jupyter.log 2>&1 &
pip 換源
1、升級
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pip -U
2、設置源
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple