问题解答
问题一:[pip]python: bad interpreter
- 问题描述
使用pip
命令安装python
库时发现了如下错误
$ pip install imgaug
-bash: /home/zj/anaconda3/envs/cv2/bin/pip: /home/zj/anaconda3/envs/cv/bin/python: bad interpreter: No such file or directory
- 问题解析
使用Anaconda
配置Python
开发环境,除了base
环境外还创建了一个新的环境cv
,后来想要配置另一套环境,就直接在envs
环境下复制了cv
,重命名为cv2
,把cv
环境给删除了
在cv2
环境下能够正常的运行Python
程序,但是使用pip
安装新库时发现了如上错误
- 解决方案
所以还是需要使用Anaconda
提供的clone
命令进行环境移植
另外在网上找到一种解决方法,就是在执行pip
命令时指定使用哪个python
$ pythoh -m pip install imgaug
问题二:AttributeError: module 'scipy.misc' has no attribute 'imread'
- 问题描述
AttributeError: module 'scipy.misc' has no attribute 'imread'
- 问题解析
scipy
版本过高
- 解决方案
$ pip install scipy==1.2.1
- 参考
解决AttributeError: module 'scipy.misc' has no attribute 'imread'报错问题
问题三:OSError: image file is truncated (24 bytes not processed)
- 问题描述
使用PIL Image
读取图片时出现如下错误:
- 问题解析
从提示信息来看,是因为图片文件太大了,PIL Image
默认不支持大图片读取
- 解决方案
参考:
OSError: image file is truncated (X bytes not processed)错误处理
OSError: image file is truncated (28 bytes not processed)
在文件头添加
from PIL import ImageFile
ImageFile.LOAD_TRUNCATED_IMAGES = True
问题四:AttributeError: module 'ssl' has no attribute 'PROTOCOL_TLSv1'
- 问题描述:
使用Miniconda
安装Python
环境,完成后使用conda/pip
安装时均出现错误
- 问题解决:
$ sudo apt install openssl
- 相关阅读
AttributeError: module 'ssl' has no attribute 'PROTOCOL_TLSv1' #1029