Anaconda
安装
关闭各类电脑管家或者安全卫士
以管理员权限运行for all users(optional)
把根目录下的Scripts文件夹路径加入环境变量
运行
根据提示先conda init cmd.exe(or powershell)
创建新环境`conda create -name new_evn [python==3.7]
给conda换源
之前的操作可能很慢,修改镜像源可解决这个问题
查看configconda config --show
#清华源
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/msys2
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
## 设置搜索时显示通道地址
conda config --set show_channel_urls yes(optional)
CondaHTTPError: HTTP 000 CONNECTION FAILED for url
除了更新镜像源(清华、中科大等),删除condarc文件中的default,还可能要把镜像地址的https改成http,因为镜像源为了提高安全性使用了ssl证书进行加密。为避免后续麻烦,可安装openssl,将其添加到环境变量中。
给pip换源
在C:\Users\xxx\AppData\Roaming
下新建pip\pip.ini
文件
#清华源
[global]
timeout = 6000
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
trusted-host = pypi.tuna.tsinghua.edu.cn
#豆瓣源
[global]
timeout = 6000
index-url = https://pypi.doubanio.com/simple
trusted-host = pypi.doubanio.com
#阿里源
[global]
timeout = 6000
index-url = https://mirrors.aliyun.com/simple
trusted-host = mirrors.aliyun.com
Jupyter
修改启动文件夹默认位置
jupyter notebook --generate-config
到对应路径下找jupyter_notebook_config.py,修改#c.NotebookApp.notebook_dir = “”'
注意拼写规则\\
之后改快捷方式的“目标”里的“%USERPROFILE%”。
连接Anaconda_env内核
方案一:可视化操作
conda install nb_conda
在相应的环境下安装ipyparallel
打开的jp主页会显示Conda菜单,进入即可可视化修改内核和管理包。
Jupyter Notebook environment anaconda3 error
修改文件~/anaconda3/pkgs/nb_conda-x.x.x-py3x.x/lib/python3.x/site-packages/nb_conda/envmanager.py
把
return {
"environments": [root_env] + [get_info(env)
for env in info['envs']]
}
改成
return {
"environments": [root_env] + [get_info(env) for env in info['envs']
if env != root_env['dir']]
}
然后重启
方案二:
查看内核情况jupyter kernelspec list
同样在相应的环境下安装ipyparallel
用命令python -m ipykernel install --name env_name
删除内核jupyter kernelspec remove --name env_name
jupyter no connection to kernel
若有卸载历史的用户先看一下内核位置是否正确(检查拼写和路径),也可能是tornado 6.*版本和jupyter当前版本不兼容,pip install xxx==xxx
降级二选一。
添加拓展包
pip install jupyter_contrib_nbextensions
jupyter contrib nbextension install --user
jp主页会显示nbextensions,注意enable。
Basemap
在Anaconda界面(base)直接安装basemap。
导入basemap模块时,报错KeyError: PROJ_LIB、FileNotFoundError:找不到epsg文件
在E:\Anaconda3\share
下新建proj
,从E:\Anaconda3\pkgs\proj4-5.2.0-h6538335_1006\Library\share
复制所有文件到E:\Anaconda3\Library\share\proj
解决epsg文件缺失,再从E:\Anaconda3\Library\share\proj
复制所有文件到之前的proj
文件夹内,新建环境变量PROJ_LIB=E:\Anaconda3\share\proj
import os
os.environ['PROJ_LIB'] = r'E:\Anaconda3\share\proj'
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt