anaconda安装好之后,有个默认的环境base,可以在anaconda powershell prompt中输入指令conda info -e进行查看,安装新的虚拟环境操作如下。
1.首先,在anaconda powershell prompt中执行以下命令更换镜像:
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/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --set show_channel_urls yes
2.建立连接,如果不进行此步,则安装的虚拟环境会在C盘,操作如下:
(1)在C盘users文件夹下找到.conda文件夹,并把这个.conda文件夹移到自己想要存放的位置,然后删除C盘的.conda文件夹。
(2)然后用管理员命令打开cmd,输入指令mklink/J "C:\Users\dongxiaofeng\.conda" "目标路径\.conda"
,目标路径自己写。
3.创建虚拟环境并安装包
(1)在anaconda powershell prompt中执行以下指令:
conda create -n 环境名称 python=3.8
“环境名称”是自己命名,为英文符,其中3.8是python的版本号
(2)默认值base环境,此时要激活自己创建的虚拟环境,在anaconda powershell prompt使用conda activate 环境名
进行激活,接下来用pip安装包,在anaconda powershell prompt中分别执行以下指令:
pip install numpy==1.18.5 -i https://pypi.douban.com/simple/
pip install tensorflow==2.3.0 -i https://pypi.douban.com/simple/
pip install keras -i https://pypi.douban.com/simple/
pip install IPython -i https://pypi.douban.com/simple/
pip install pydotplus -i https://pypi.douban.com/simple/
conda install basemap
pip install pyproj -i https://pypi.douban.com/simple/
pip install geos -i https://pypi.douban.com/simple/
pip install matplotlib -i https://pypi.douban.com/simple/
pip install scikit-learn -i https://pypi.douban.com/simple/
pip install scikit-image -i https://pypi.douban.com/simple/
conda install pandas
pip install scipy -i https://pypi.douban.com/simple/
pip install graphviz-i https://pypi.douban.com/simple/
pip install mlxtend -i https://pypi.douban.com/simple/
pip install xgboost -i https://pypi.douban.com/simple/
pip install seaborn -i https://pypi.douban.com/simple/
pip install jupyter -i https://pypi.douban.com/simple/
其中,mlpy这个库需要本地安装,先下载mlpy轮子文件,然后在mlpy所在的文件夹中执行指令pip install mlpy-3.5.0-cp38-cp38-win_amd64.whl
(我下载的是这个文件),就可以了。
以上,是我同学帮助我的,再次感谢那个同学。