Anaconda环境搭建
Anaconda环境搭建
一、创建环境 创建命令:conda create -n env_name python=3.xenv_name : 环境名
python=2.x/3.x :指定python版本
示例:
conda create -n py36 python=3.6
创建名py36的环境,python版本为3.6
克隆环境
conda create -n env_new --clone env_base
source activate my_env (OSX/LINUX系统)
activate my_env (Windows系统) #示例:activate py36
conda install package_name #示例:conda install numpy/scipy
环境中删除所需的包:conda remove package_name
删除环境:conda remove -n my_env --all
三 Anaconda瘦身 方法1 Anaconda就像一个相对独立的生态,默认情况下,conda 创建的新环境 以及过往安装的模块缓存都存储在用户目录下,这一点不会在 conda (user-specific)配置文件 $HOME/.condarc 中体现出来,除非用户修改了默认设置。我们可以使用conda info查看C:UsersXXXX>conda info active environment : None shell level : 0 user config file : C:UsersXXXX.condarc populated config files : conda version : 4.5.11 conda-build version : 3.10.5 python version : 3.6.5.final.0 base environment : C:Anaconda3 (writable) channel URLs : https://repo.anaconda.com/pkgs/main/win-64 https://repo.anaconda.com/pkgs/main/noarch https://repo.anaconda.com/pkgs/free/win-64 https://repo.anaconda.com/pkgs/free/noarch https://repo.anaconda.com/pkgs/r/win-64 https://repo.anaconda.com/pkgs/r/noarch https://repo.anaconda.com/pkgs/pro/win-64 https://repo.anaconda.com/pkgs/pro/noarch https://repo.anaconda.com/pkgs/msys2/win-64 https://repo.anaconda.com/pkgs/msys2/noarch package cache : C:Anaconda3pkgs C:UsersXXXXAppDataLocalcondacondapkgs envs directories : C:Anaconda3envs C:UsersXXXXAppDataLocalcondacondaenvs C:UsersXXXX.condaenvs platform : win-64 user-agent : conda/4.5.11 requests/2.18.4 CPython/3.6.5 Windows/10 Windows/10.0.17134 administrator : False netrc file : None offline mode : False
123456789101112131415161718192021222324252627282930 修改conda环境和缓存的默认路径(envs directories 和 package cache)。路径的设置可以通过编辑 $HOME/.condarc 来实现。添加或修改 $HOME/.condarc 中的 env_dirs 和 pkgs_dirs 配置项分别设置环境和缓存路径,按顺序第一个路径作为默认存储路径,搜索环境和缓存时按先后顺序在各目录中查找。
channels: - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/ - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ - defaultsshow_channel_urls: trueenvs_dirs: - D:dataxxxxMinicondaenvs # 此处为修改后的目录 - C:UsersxxxxAppDataLocalcondacondaenvs - C:Usersxxxx.condaenvs - C:ProgramDataAnacondaMiniconda3envspkgs_dirs: - D:dataxxxxMinicondapkgs # 此处为修改后的目录 - C:UsersxxxxAppDataLocalcondacondapkgs - C:Usersxxx.conda - C:ProgramDataAnacondaMiniconda3pkgs 123456789101112131415 方法2
使用conda clean命令
第一步:通过conda clean -p来删除一些没用的包,这个命令会检查哪些包没有在包缓存中被应用依赖到其他地方,并删除它们。
第二步:通过conda clean -t删除conda保存下来的tar包(删除后,以后安装要重新下载的)。
或者直接只用conda clean -y -all 删除所有的安装包及cache
执行命令:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --set show_channel_urls yes
执行命令:conda config --set show_channel_urls yes
2.1 目录 C:Users<用户名> 下生成配置文件.condarc,文件内容如下(notepad++打开):
2.2 删除上述配置文件 .condarc 中的第三行,然后保存,效果如下:
执行命令:conda info
查看当前配置信息,内容如下,即修改成功,关注 channel URLs 字段内容
使用虚拟环境的jupyter notebook方法:
以下示例的torch_0.31可修改为你自己的环境名,
# 创建环境 torch_0.31 conda create -n torch_0.31 python=3.6.6 # 激活环境 conda activate torch_0.31 # 安装依赖包 conda install ipykernel # 创建虚拟jupyter环境 python -m ipykernel install --user --name torch_0.31 --display-name "python_torch_0.31" # 远程终端无浏览器启动 nohup jupyter notebook --no-browser --port=8888 --ip=* --allow-root > /home/xxx/jupyter.log 2>&1 & cat jupyter.log # 本地查看 http://192.168.888.888:8888/?token=da2a3428ebfbe1cb67c0207dc52575fee54b8875b67bf0b3
123456789101112131415161718 六、conda pip 设置代理服务器(linux)vim ~/.condarc 注意空格,否则会报错
channels: - https://pypi.tuna.tsinghua.edu.cn/simple - https://mirror.baidu.com/pypi/simple show_channel_urls: true proxy_servers: http: http://ip:port https: https://ip:port ssl_verify: false 123456789
运行conda install xxx报错:
Collecting package metadata (current_repodata.json): failed UnavailableInvalidChannel: The channel is not accessible or is invalid. channel name: simple channel url: https://pypi.tuna.tsinghua.edu.cn/simple error code: 404 You will need to adjust your conda configuration to proceed. Use `conda config --show channels` to view your configuration's current state, and use `conda config --show-sources` to view config file locations. 12345678910
意思是资源路径无效或无法访问;资源的url地址是 http://pypi.douban.com/simple,错误代码是404。
404是指链接指向的网页不存在,即原始网页的URL失效。
执行恢复:conda config --remove-key channels
执行:conda config --remove-key channels 移除添加的频道。
cat .condarc
show_channel_urls: true proxy_servers: http: http://xxx.xxx.xxx.x:xxxx https: https://xxx.xxx.xxx.x:xxxx ssl_verify: false 123456
参考:https://www.cnblogs.com/zengming/p/12057656.html
附加:jupyter notebook 使用方法 镜像下载地址 ubuntu系统镜像: Ubuntu官网:http://mirror.pnl.gov/releases/xenial/中科大源: http://mirrors.ustc.edu.cn/ubuntu-releases/
阿里云开源镜像站: http://mirrors.aliyun.com/ubuntu-releases/
兰州大学开源镜像站: http://mirror.lzu.edu.cn/ubuntu-releases/
北京理工大学开源: http://mirror.bit.edu.cn/ubuntu-releases/
浙江大学: http://mirrors.zju.edu.cn/ubuntu-releases/
老的镜像: http://old-releases.ubuntu.com/releases/ Anaconda镜像: 清华镜像站:https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/
Anaconda各版本下载:https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/ Pytorch镜像 Pytorch镜像下载:https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/win-64/
CentOS安装Anaconda:报错:Exiting with failure status due to previous errors
安装bzip2即可解决:yum install -y bzip2
cd PyInstaller-3.6
python3 setup.py build
python3 setup.py install
Python 使用清华大学镜像源安装依赖包
临时使用:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple <包名>
永久修改镜像源:
pip install pip -U
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
网络不好则使用这个
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pip -U
安装opencv-python 报错:
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError("bad handshake: Error([('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')],)",),)': /packages/72/c2/e9cf54ae5b1102020ef895866a67cb2e1aef72f16dd1fde5b5fb1495ad9c/opencv_python-4.2.0.34-cp36-cp36m-manylinux1_x86_64.whl
解决方法:pip install <包名> -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
https://www.jianshu.com/p/1f00e47298f1
https://www.cnblogs.com/carey9420/p/11983468.html
相关知识
pytorch python=3.6环境安装
UE4搭建标准光照环境
基于YOLO的植物病害识别系统:从训练到部署全攻略
搭建 本地高效Shopify开发环境完美解决方案
基于卷积神经网络的樱桃叶片病虫害识别与防治系统,vgg16,resnet,swintransformer,模型融合(pytorch框架,python代码)
基于卷积神经网络的玉米病虫害识别与防治系统,vgg16,resnet,swintransformer,模型融合(pytorch框架,python代码)
基于卷积神经网络的苹果叶片病虫害识别与防治系统,vgg16,resnet,swintransformer,模型融合(pytorch框架,python代码)
基于卷积神经网络的桃子叶片病虫害识别与防治系统,vgg16,resnet,swintransformer,模型融合(pytorch框架,python代码)
基于卷积神经网络的农作物病虫害识别与防治系统,vgg16,resnet,swintransformer,模型融合(pytorch框架,python代码)
探索自然之美:基于Yolov5的海棠花花朵检测识别项目
网址: Anaconda环境搭建 https://www.huajiangbk.com/newsview1125710.html
上一篇: Linux系统下利用anacon |
下一篇: Mac系统下的Pycharm怎么 |
推荐分享

- 1君子兰什么品种最名贵 十大名 4012
- 2世界上最名贵的10种兰花图片 3364
- 3花圈挽联怎么写? 3286
- 4迷信说家里不能放假花 家里摆 1878
- 5香山红叶什么时候红 1493
- 6花的意思,花的解释,花的拼音 1210
- 7教师节送什么花最合适 1167
- 8勿忘我花图片 1103
- 9橄榄枝的象征意义 1093
- 10洛阳的市花 1039