anaconda常用命令及常见错误与解决方法

一、常用命令

用pip安装依赖包时,默认是从国外下载,可以指定国内源,速度飞快
pip install -i 国内镜像地址 包名
例如: pip install -i https://mirrors.aliyun.com/pypi/simple/ numpy

      国内常用pip镜像地址

清华:https://pypi.tuna.tsinghua.edu.cn/simple

阿里云:https://mirrors.aliyun.com/pypi/simple/

豆瓣:  https://pypi.douban.com/simple/  --trusted-host pypi.douban.com

--ignore-installed --upgrade:忽略已安装的升级

--no-dependencies: 忽略版本依赖关系

--force-reinstall :强制重新安装

  pip install  --ignore-installed --upgrade  tensorflow 

百度:https://mirror.baidu.com/pypi/simple

中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/

华中理工大学:https://pypi.hustunique.com/

山东理工大学:https://pypi.sdutlinux.org/

       国内常用conda镜像地址 

中科大:--channel https://mirrors.ustc.edu.cn/anaconda/pkgs/free

例如 conda install --channel https://conda .anaconda.ort/pandas bottleneck

conda install安装不成功时加--channel conda-forge :  例如    conda install --channel conda-forge

-c bioconda    例如 :conda install -c bioconda sra-tools  conda install -c bioconda/label/cf201901 sra-tools

查看源:conda config --show-sources

恢复官方镜像源:conda config --remove-key channels

创建 .condarc文件: conda config --set show_channel_urls yes

清除索引缓存 :conda clean -i

查看conda版本: conda --version

升级conda版本: conda update conda

升级conda所有包:conda update --all

创建环境tensorflow,并指定python=3.7:conda create -n tensorflow python=3.7

激活环境:windows用户: conda activate tensorflow     linux用户:  source activate tensorflow

退出环境:windows用户:deactivate     linux用户:  source deactivate

复制一个环境:克隆tensorflow来创建一个称为tensorflow2的副本  :    conda create -n tensorflow2  --clone tensorflow

通过环境文件创建环境:conda env create -f environment.yaml

提升到root权限   sudo -s

二、常见错误与解决方法

ERROR: Cannot uninstall 'wrapt'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.  解决办法

pip install -U --ignore-installed wrapt enum34 simplejson netaddr

jupyter notebook出现kernel error解决办法

使用命令查看jupyter的内核是否是正确的内核

jupyter kernelspec list

如果不正确,使用jupyter kernelspec remove 内核名 删除掉内核

jupyter kernelspec remove 

使用python -m ipykernel install --user 安装内核,再安装pypiwin32   wrapt

python -m ipykernel install --user

pip install -i https://pypi.douban.com/simple pypiwin32
pip install wrapt --ignore-installed

Jupyter Notebook——Windows平台上中如何切换虚拟环境

装插件会出现Conda选项卡,然后再安装jupyter    conda install jupyter

conda install nb_conda
conda install jupyter

错误:No matching distribution found for torch==1.4.0 (from torchvision)

解决办法

pip install --no-deps torchvision

启动jupyter notebook 出现ModuleNotFoundError:jupyter_nbextensions_configurator

解决办法 在 Anaconda Prompt 终端执行 python3.7 -m pip install jupyter_contrib_nbextensions;其中python3.7 是你安装python的版本

python3.7 -m pip install jupyter_contrib_nbextensions

ModuleNotFoundError: No module named 'IPython.core.inputtransformer2

解决办法 

pip install ipython --ignore-installed ipython

两条命令完美解决ModuleNotFoundError: No module named pip._internal

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py --force-reinstall

Anaconda Navigator打不开,没有任何反应

conda update conda
conda update --all

python中IDLE打不开,提示IDLE's subprocess didn't make connection的解决方案

修改[Python目录]\Lib\idlelib\PyShell.py文件bai,在du1300行附近,将zhi

def main():函数下面

use_subprocess = True

修改为:dao

use_subprocess = False

安装python api时报错ModuleNotFoundError: No module named '_ctypes'

先安装libffi-devel 再编译python3.7

Ubuntu

Sudo apt-get install libffi-dev

Centos

Yum install libffi-devel -y

Windows 10 SDK 下载地址

Windows 10 SDK - Windows app development

关闭tensorflow警告

Import os
os.environ['TF_CPP_MIN_LOG_LEVEL']='2'

使用 PPA 第三方软件仓库安装最新版本

添加 PPA 软件仓库,需要输入用户密码,更新软件索引

sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update

AttributeError module 'keras_applications' has no attribute 'set_keras_submodules'   解决

pip install keras-models

python3.7安装, 解决pip is configured with locations that require TLS/SSL问题

查阅资料之后发现:在./configure过程中,如果没有加上–with-ssl参数时,默认安装的软件涉及到ssl的功能不可用,
刚好pip3过程需要ssl模块,而由于没有指定,所以该功能不可用

./configure --prefix=/usr/local/python3 --with-ssl

ValueError: Object arrays cannot be loaded when allow_pickle=False解决方案

numpy版本太高,降级为1.16.2

pip install numpy==1.16.2

Python : ModuleNotFoundError: No module named ‘win32com‘解决办法

pip install pypiwin32

删除Mysql80服务,进入cmd 输入sc delete MySQL80

sc delete MySQL80

一直提示提交错误报告,这可能是防火墙问题,使用命令

conda config --set ssl_verify false

No module named 'yaml'错误解决办法

pip install pyyaml

Error #15: Initializing libiomp5md.dll, but found libiomp5md.dll already initialized.解决方案

import os
os.environ["KMP_DUPLICATE_LIB_OK"] = "TRUE"

pyqt5问题,无法使用jupyter  spyder打不开 

pip install pyqt5==5.12.3 pyqtwebengine==5.12.1

你可能感兴趣的:(深度学习,tensorflow,自然语言处理)