删除 ENV 目录下的 python 环境
rm -rf ENV
创建新 python 环境 在 目录 ENV下
conda create -p ENV python=3.6
在ENV 目录 环境下安装 指定软件
./ENV/bin/pip install numpy
查找python 项目依赖并生成到 requirements.txt
./ENV/bin/pip freeze >requirements.txt
conda 设置虚拟环境
在机器上可以设置多套 虚拟 python 运行环境,在不同的运行环境安装不同版本,或者不同的依赖包。
查看已经创建好的环境
conda info --envs
创建虚拟环境
conda create --name bf-predict-env python=3.6.3
复制虚拟环境
conda create -n snows --clone env
切换新环境
切换到新环境
linux/Mac下需要使用
source activate env_name
source full/path/to/env
Windows 下需要使用
activate env_name
#退出环境,也可以使用activate root切回root环境
deactivate env_name
Note:这步很关键,清华镜像上默认的pystan=2.14.0.0, 安装上去,调用 fit 的时候回报错,需要更新到最新版本
conda create --name bf-predict-env pystan=2.18.0.0
选定环境
source activate bf-predict-env
在当前选定的环境上安装包
source activate bf-predict-env
conda install --name bf-predict-env fbprophet
停用环境
source deactivate
删除 环境
conda remove --name bf-predict-env --all
查看安装的包
conda list
如何在 notebook 上激活本地虚拟环境,部署完成后可以选择本地的虚拟环境conda
首先激活对应的conda环境
source activate bf-predict-env
安装 ipykernel
conda install --name bf-predict-env ipykernel
将环境写入notebook的kernel中
(bf-predict-env) localhost:prophet-master user$ python -m ipykernel install --user --name bf-predict-env --display-name ‘Python bf-predict-env’
上述操作完成后会报错, ImportError: No Module Named ‘pysqlite2’,执行
conda install --name bf-predict-env sqlite
conda install --name bf-predict-env python=3.6
启动notebook 即可
jupyter notebook
localhost 未发送任何数据。
断开网络加速,不能翻墙,否则浏览器页面会报此错误
install fastai (包含 pytorch)
conda install -c pytorch -c fastai fastai pytorch
在conda 环境,可以切换成 pip 安装源码包,
pip install -e .
安装sklearn
conda install scikit-learn
安装 bert-serving 服务
https://pypi.org/project/bert-serving-server/
conda install tensorflow
pip install bert-serving-server # server
pip install bert-serving-client # client, independent ofbert-serving-server
启动 jupyter notebook 时报错, ImportError: cannot import name ‘ensure_dir_exists’. You need to update jupyter_core, and jupyter_client
conda update jupyter_core jupyter_client
To install tensorflow-hub package with conda run one of the following:
conda install -c conda-forge tensorflow-hub
conda install -c conda-forge/label/gcc7 tensorflow-hub
conda install -c conda-forge/label/cf201901 tensorflow-hub
在 notebook 中安装 包,报错 PermissionError, 后面加 --user jupyter
pip install --user jupyter works like a charm. Thanks.
!pip install bert-tensorflow --user jupyter
本文介绍了如何使用conda创建、切换和管理Python虚拟环境,包括安装特定版本的Python、安装包、生成环境依赖文件、激活与停用环境、复制环境、删除环境,以及在Jupyter Notebook中使用本地虚拟环境的方法。同时,提到了处理环境中遇到的模块导入错误和安装特定包的技巧。
8269

被折叠的 条评论
为什么被折叠?



