conda环境搭建
2021-12-14 21:38 雄风狂飙 阅读(286) 评论(0) 收藏 举报1、下载并安装
https://www.anaconda.com/products/individual
2、创建环境
查看环境:conda env list
创建虚拟环境: conda create -n my_py_env python=3.6.2
(
用指定目录的方式安装tensorflow一直报错。
使用conda create -n sentiment python=3.8
然后 activate sentiment的方式可以正常使用
安装tensorflow也可以 conda install tensorflow
用canda 安装jupyter 失败,就是用pip安装 pip install jupyter
用canda安装sklearn失败,
)
指定目录创建环境:conda create --prefix="D:\\yourdir1\\dir2\\yourenv" python=3.6.3
激活环境:activate my_py_env
指定目录激活: activate D:\yourdir1\dir2\yourenv
退出环境:deactivate
使用conda安装包:conda install -n my_py_env package_name
删除环境:conda remove -n my_py_env --all
来自---
https://www.jianshu.com/p/240e396e495f
3、遇到错误
CondaHTTPError: HTTP 000 CONNECTION FAILED for url
执行:
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/win-64
conda config --set show_channel_urls yes
打开
C:\Users\Lenovo\.condarc ,如下:
show_channel_urls: true
channels:
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/win-64
- http://mirrors.ustc.edu.cn/anaconda/pkgs/free/
注意:如果后面有 - default ,请删除这一行
如果遇到权限不足的,请用管理员运行cmd
------其他错误
问题:下载太慢
可以手工临时增加镜像
pip install tensorflow==1.15.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
问题:找不到gensim
排查:明确已经下载了gensim,使用conda install gensim 下载的,并且在本环境下面下载的。
解决办法:1、通过anaconda navigator在base下面下载了gensim;2、在cmd下面执行python,然后 import gensim,发现有warning如下:
F:\pythonProject\anaconda\sentiment\lib\site-packages\gensim\similarities\__init__.py:15: UserWarning: The gensim.similarities.levenshtein submodule is disabled, because the optional Levenshtein package <https://pypi.org/project/python-Levenshtein/> is unavailable. Install Levenhstein (e.g. `pip install python-Levenshtein`) to suppress this warning.
warnings.warn(msg)
然后 conda install python-Levenshtein
也不知道是由于1还是2,之后,在jupyter notebook中使用import gensim就没有报错了。
问题:报错说
No module named 'tensorflow'
解决:先卸载jupyter, 然后使用pip安装jupyter居然就好了
问题:jupyter 报错一直在重新启动
解决办法是:conda uninstall -n sent4 tornada
我的tornado原来是6.1,我安装程5.1.1,就好了
conda install -n sent4 tornado=5.1.1
有时候还会出现一个问题,就是启动jupyter notebook说命令找不到的奇怪错误
使用conda卸载,conda uninstall -n sent4 jupyter
然后使用pip安装 ,pip install jupyter
居然就是可以使用了,真是日乐购。。
问题:tensor很多时候报错tensorflow-estimator的错误
需要使用tensorflow 1.15.0 和 tensorflow-estimator 1.15.1 一起使用
使用tensorflow-estimator1.15.1 和tensorflow 1.15.0 搭配是没有问题,但是有时候需要用pip安装tensorflow,然后用pip安装tensorflow-estimator才可以。
卸载命令是:conda的命令 conda uninstall -n sent4 tensorflow
conda uninstall -n sent4 tensorflow-estimator
pip的命令 pip uninstall tensorflow
pip uninstall tensorflow-estimator
安装命令: pip install tensorflow==1.15.0
pip install tensorflow-estimator=1.15.1
浙公网安备 33010602011771号