文章目录
- 1、`Amodule ‘os‘ has no attribute ‘add_dll_directory‘`
- 2、`SyntaxError: future feature annotations is not defined`
- 3、`no moudled named 'numpy.core._multiarray_umath'`
- 4、`cannot import name 'Literal' from 'typing'`
- 5、no module named 'XXX'解决办法
- 6、module 'numpy' has no attribute 'ndarray'
- 7、module’ object is not callable
- 8、ValueError: I/O operation on closed file.
- 9、type object 'Image' has no attribute 'open'
1、Amodule ‘os‘ has no attribute ‘add_dll_directory‘
2、SyntaxError: future feature annotations is not defined
3、no moudled named 'numpy.core._multiarray_umath'
- numpy版本与python版本不一致
- 下载地址:numpy · PyPI
- cp37表示python版本
4、cannot import name 'Literal' from 'typing'
- 解决spider导入库出现ImportError: cannot import name ‘Literal‘ from ‘typing‘问题
- 方法1:升级python版本到3.8及以上
- 方法2:修改pandas文件
- 下载
typing_extensions
- 然后根据报错信息修改代码,会提示路径以及错误信息,在某一个
__init__.py
里
- 下载
try:
from typing import Literal
except ImportError:
from typing_extensionsimport Literal
5、no module named 'XXX’解决办法
- 在PyPI搜索对应的module下载,选择对应Python的版本下载安装
- 出现no module named 'google’时,需要在网站
https://pypi.org/
搜索protobuf
下载,不能直接搜索google,注意下载版本需要匹配
6、module ‘numpy’ has no attribute ‘ndarray’
- 名字取错(如取名为
numpy.py
与numpy
库相同)或者numpy和pandas的版本不匹配 - 关于AttributeError: module ‘numpy‘ has no attribute ‘ndarray‘的问题解决
- AttributeError: module ‘numpy‘ has no attribute ‘ndarray‘(最新版解决,综合多篇)
7、module’ object is not callable
8、ValueError: I/O operation on closed file.
- 若使用了
with open() as f
语句- 检查对文件的操作语句是都在with语句内(检查语句对没对齐)
9、type object ‘Image’ has no attribute ‘open’
- 导入了Image和ImageTK包还是会报这个错误
- 结果是由于我在Tools里面使用了tkinter,导致有tkinter包在Image后面导入,库的顺序不对报错