Skip to content

问题解答

问题一:[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