Python问题汇总

1.汉字无法显示

# -*- coding: UTF-8 -*-

将源码文件编码格式改成UTF-8

2.AttributeError: module 'numpy' has no attribute 'arange'

在工作目录中存在一个自己创建的numpy.py文件

3.ImportError: No module named 'pip'

apt-get install python3-pip

4.ImportError: No module named 'torch'

sudo pip install torchvision

5.ImportError: No module named 'dateutil'

sudo pip install python-dateutil

6.ImportError: No module named 'SSIM'

pip install pyssim

如果还不行把代码中的SSIM,改成ssim


 

7.第三方软件安装

指定超时时间

python -m pip --default-timeout=100 install pymysql

指定源

python -m pip --default-timeout=200 install -i https://pypi.douban.com/simple/ -U pymysql

python -m pip install --upgrade pip -i https://pypi.douban.com/simple/

8.ImportError: No module named numpy

sudo apt-get install python-numpy

 pip install numpy

9.pip: no module named _internal

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

python2.7 get-pip.py --force-reinstall

10.ImportError: No module named setuptools

11.ImportError: No module named skimage.io

sudo pip install scikit-image

12.Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build*

sudo python -m pip install --upgrade --force pip

13.ImportError: No module named google.protobuf.internal

sudo pip install protobuf

版本问题

安装各种依赖时,经常会遇到版本不匹配的问题,可以安装aptitude解决,非常好用

sudo apt-get install aptitude

sudo apttitude install python3.6-dev

 

你可能感兴趣的:(工作笔记)