栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

重装Anaconda,指定虚拟环境路径,清华源,Jupyter,zipline

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

重装Anaconda,指定虚拟环境路径,清华源,Jupyter,zipline

重装Anaconda,指定虚拟环境路径,清华源,Jupyter,zipline
  • 前言:使用conda命令不成功的时候,查官网文档。
    • 1、 清理虚拟环境&卸载anaconda:
    • 2、下载Anaconda官网
      • 2.1 [下载官网——https://www.anaconda.com/](https://www.anaconda.com/)
      • 2.2 安装地址:自行选择 ,关系到下文的环境变量配置
    • 3、配置环境
    • 4、清华镜像配置
      • 4.1 创建 .condarc 镜像配置文件
      • 4.2 配置文件.condarc文件内容
    • 5、安装虚拟环境到指定目录
      • 5.1 管理员创建虚拟环境并指定python版本
      • 5.2 查看多少个环境
    • 6、配置jupyter
      • 6.1 安装ipykernel
    • 7、安装zipline
    • 8、总结
      • 8.1 在创建虚拟环境的时候需要管理员权限,
      • 8.2 在安装zipline的时候需要用到管理员权限(PowerShell的activate不可以用,还是用了黑窗的cmd的activate来激活环境。)
      • 8.3 安装ipykernel的时候,如果用了梯子,会有Http连接问题,关掉梯子就好了。
      • 9.彩蛋

前言:使用conda命令不成功的时候,查官网文档。

在上述操作过程中,常常需要使用管理员权限,主要是跟我安装Anaconda的时候用了管理员权限运行,我做了重装anaconda的重装的时候没有选择管理员权限启动Anaconda.exe,就很少这种情况了。

1、 清理虚拟环境&卸载anaconda:

参考文献:Anaconda3彻底卸载+重新安装Aanconda+tensorflow+keras——https://blog.csdn.net/qq_38938670/article/details/108308132

1.1 code命令

conda install anaconda-clean

anaconda-clean --yes

1.2 从安装路径卸载:

Uninstall-Anaconda3.exe

2、下载Anaconda官网 2.1 下载官网——https://www.anaconda.com/ 2.2 安装地址:自行选择 ,关系到下文的环境变量配置

我的是:D:AworkStationAnaconda3

3、配置环境

环境变量配置如下

D:AworkStationAnaconda3;D:AworkStationAnaconda3Librarymingw-w64bin;D:AworkStationAnaconda3Libraryusrbin;D:AworkStationAnaconda3Librarybin;D:AworkStationAnaconda3Scripts;

在这里插入代码片

4、清华镜像配置

清华镜像配置参考网址——https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/

4.1 创建 .condarc 镜像配置文件
# 在cmd窗口(命令提示符)
conda config --set show_channel_urls yes


# 清理索引缓存
conda clean -i
4.2 配置文件.condarc文件内容

在个人用户文件下找到.condarc文件,添加以下内容:

channels:
  - defaults
show_channel_urls: true
default_channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
  conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
5、安装虚拟环境到指定目录 5.1 管理员创建虚拟环境并指定python版本

需要使用管理员权限打开cmd, 并在此路径D:AworkStationAnaconda3envsquan_py36
cmd(PowerShell):

conda create -p D:AworkStationAnaconda3envsquan_py38 python=3.8
5.2 查看多少个环境
PS C:WINDOWSsystem32> conda env list
# conda environments:
#
base                  *  D:AworkStationAnaconda3
quan_py38                D:AworkStationAnaconda3envsquan_py38

PS C:WINDOWSsystem32>
6、配置jupyter 6.1 安装ipykernel

参考文献——添加或删除jupyter notebook虚拟环境——https://blog.csdn.net/qq_43203949/article/details/108524056

conda install ipykernel

# 配置指定环境quan_py38
python -m ipykernel install --name quan_py38
7、安装zipline

参考网址:https://zipline.ml4trading.io/install.html

实测只有python3.8以上才可以支持,当前blog中的py36,py35是失败的。

# 激活虚拟环境
conda activate quan_py38
# 安装zipline
conda install -c ml4t -c conda-forge -c ranaroussi zipline-reloaded
8、总结

在上述操作过程中,常常需要使用管理员权限,主要是跟我安装Anaconda的时候用了管理员权限运行,我做了重装anaconda的重装的时候没有选择管理员权限启动Anaconda.exe,就很少这种情况了。
所以为了方便,可以安装个人权限的Anaconda.exe

8.1 在创建虚拟环境的时候需要管理员权限, 8.2 在安装zipline的时候需要用到管理员权限(PowerShell的activate不可以用,还是用了黑窗的cmd的activate来激活环境。) 8.3 安装ipykernel的时候,如果用了梯子,会有Http连接问题,关掉梯子就好了。


【网上有其他解决方案——参考文献:https://blog.csdn.net/my_wings/article/details/106572949:】说的是用anaconda的 prompt

9.彩蛋

常用官网:
sklearn——https://scikit-learn.org/stable/install.html
sklearn&Github——https://github.com/scikit-learn/scikit-learn
Anaconda——https://docs.anaconda.com/anaconda/install/windows/
Oracle——https://docs.oracle.com/en/database/oracle/oracle-database/index.html
conda-forge&GitHub——https://github.com/conda-forge/miniforge

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/889414.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号