conda pip python 安装常用口令
conda
windows下常用指令:
1.创建python版本为3.5的虚拟环境,命名为Python3
conda create -n Python3 python=3.5
2.使用/**/切换虚拟环境Python3
activate Python3
3.在虚拟环境Python3中安装包
如果已经在虚拟环境中,可以直接安装
pip install XXX
也可以使用conda命令安装到虚拟环境中
conda install -n Python3 xxx
4.退出虚拟环境
deactivatePython3
5.删除虚拟环境Python3
conda remove -n Python3 --all
6.删除虚拟环境Python3中的某个安装包
conda remove --n Python3 xxx
7.删除虚拟环境Python3中的某个安装包
conda info --envs
8.查看环境列表
conda env list
————————————————
原文链接:https://blog.****.net/v1_vivian/article/details/78418660
pip
指定源安装
清华源安装:例如以下
pip install torch -i https://pypi.tuna.tsinghua.edu.cn/simple
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple
中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple
阿里云 http://mirrors.aliyun.com/pypi/simple
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple
豆瓣 (douban) http://pypi.douban.com/simple
注意:以上源地址为下面的index-url部分,关于–trusted-host(即host域名)部分,就取index-url中http(s)????/ 到第一个/之间的部分,请使用者自行对应提取
在windows环境下修改pip镜像源的方法(以python3.6为例)
(1):在windows文件管理器中,输入 %APPDATA%
(2):会定位到一个新的目录下,在该目录下新建pip文件夹,然后到pip文件夹里面去新建个pip.ini文件
(3):在新建的pip.ini文件中输入以下内容,搞定文件路径:“C:\Users\Admin\AppData\Roaming\pip\pip.ini”
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = pypi.tuna.tsinghua.edu.cn
常见问题
1.pip装torch 时候报:
ImportError: No module named ‘tools.nnwrap’
Command “C:\ProgramData\Anaconda2\envs\tf1.4\python.exe -u -c “import setuptools, tokenize;file=‘C:\Users\Public\Documents\Wondershare\CreatorTemp\pip-build-v8n0a4fg\torch\setup.py’;f=getattr(tokenize, ‘open’, open)(__
file__);code=f.read().replace(’\r\n’, ‘\n’);f.close();exec(compile(code, file, ‘exec’))” install --record C:\Users\Public\Documents\Wondershare\CreatorTemp\pip-9nimeizm-record\install-record.txt --single-version-externally-man
aged --compile” failed with error code 1 in C:\Users\Public\Documents\Wondershare\CreatorTemp\pip-build-v8n0a4fg\torch
解决从官网找到指定版本,下载
最后在PyTorch官网利用其提供的安装命令,成功安装torch库。
根据自己的python版本和电脑配置选择安装命令
连接:https://pytorch.org/