如何将Google Cloud AI Platform Jupyter Lab升级到Python 3.7+ [英] How to upgrade Google Cloud AI Platform Jupyter Lab to Python 3.7+
问题描述
Google Cloud Platform的AI平台可方便地部署Jupyter Lab,但仅适用于Python 2和Python 3.5.3.如何升级实例以能够运行Python 3.7(或更高版本)笔记本?
Google Cloud Platform's AI Platform has convenient deployment of Jupyter Lab, but only for Python 2 and Python 3.5.3. How can I upgrade my instance to be able to run Python 3.7 (or higher) notebooks?
推荐答案
此解决方案基于 如何让python 3.7在Google Cloud Platform的AI Platform Notebook实例上运行,该实例随附
How to get python 3.7 working on Google Cloud Platform's AI Platform Notebook Instances, which comes with built-in support for JupyterLab, but is only updated to python 3.5.3:
-
创建或使用现有的笔记本实例.
单击OPEN JUPYTERLAB按钮以在浏览器中启动JupyterLab.在JupyterLab中,打开一个新终端以jupyter用户身份安装(文件">新建">终端").不要SSH进入您的实例!同样,不要使用GCP Shell.
Click on the OPEN JUPYTERLAB button to launch JupyterLab in your brower. Within JupyterLab, open a new terminal to install as the jupyter user (File > New > Terminal). Don't SSH into your instance! Again, don't use the GCP shell.
按照以下命令安装新版本的python(此处为3.7.4):
Follow these commands to install the new version of python (here is 3.7.4):
# install necessary command-line tools and packages
sudo apt-get install -y build-essential checkinstall libreadline-gplv2-dev libncursesw5-dev \
libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev zlib1g-dev openssl \
libffi-dev python3-dev python3-setuptools wget liblzma-dev
#install pyenv to install python on persistent home directory
curl https://pyenv.run | bash
# add to path
echo 'export PATH="$HOME/.pyenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc
source ~/.bashrc
# install python 3.7.4 (will take a while) and make default
pyenv install 3.7.4
pyenv global 3.7.4
python -m pip install ipykernel
python -m ipykernel install --user --name python-37 --display-name "Python 3.7"
- 现在,您需要关闭并重新启动JupyterLab实例(如步骤2所示).当您打开任何.ipynb文件时,Python 3.7现在应该在您的内核下拉列表中可用.
请注意,您将需要重新安装代码所依赖的所有软件包,例如pandas
和scikit-learn
.同样,从终端"窗口中进行安装.例如:
Note that you will need to re-install any packages your code depends on, like pandas
and scikit-learn
. Again, do the installing from the Terminal window. For example:
pip install pandas scikit-learn joblib imbalanced-learn pymongo matplotlib nltk
这篇关于如何将Google Cloud AI Platform Jupyter Lab升级到Python 3.7+的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!