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

pypi.org :    https://pypi.org/simple    

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

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

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

  pip install  --ignore-installed --upgrade  tensorflow 

 pip install --no-cache-dir --force-reinstall --no-binary :all: scikit-learn

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

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

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

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

pip install mxnet-cu102 -f https://dist.mxnet.io/python 

       国内常用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

conda create -n name --override-channels -c conda-forge

激活环境: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

创建虚拟环境   python -m venv py38

二、常见错误与解决方法

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 -i https://pypi.tuna.tsinghua.edu.cn/simple pyqt5==5.12.3 pyqtwebengine==5.12.1

 ipynb文批处理转化为普通的Python文件

jupyter nbconvert --to script *.ipynb

nvidia nano import torch时报OSError: libmpi_cxx.so.20: cannot open shared object file: No such file or

sudo apt-get install libopenblas-base libopenmpi-dev 

ImportError: libgthread-2.0.so.0: cannot open shared object file: No such file or directory

sudo apt-get install libglib2.0-0

linux安装nvidia驱动 

加-no x check就可以正常安装

1.将当前目录下所有.txt文件打包并压缩归档到文件this.tar.gz,我们可以使用
tar czvf this.tar.gz ./*.txt 
2.将当前目录下的this.tar.gz中的文件解压到当前目录我们可以使用
tar xzvf this.tar.gz ./

 mininet是一个仿真工具,能够仿真一个SDN网络,包含主机、交换机、控制器和链路组成的虚拟网络。开拓扑指令

sudo mn --topo=tree,3,2 --controller=remote --switch=ovsk

  • 6
    点赞
  • 30
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

纬领网络

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值