Python3.6 ModuleNotFoundError: No module named 'Cryptodome'解决方法

现象

之前在Mac上进行运行的程序突然不行了,报错提示ModuleNotFoundError: No module named 'Cryptodome'

www:edm user$ python3.6 crawl.py 
Traceback (most recent call last):
  File "crawl.py", line 9, in <module>
    from Cryptodome.Cipher import AES
ModuleNotFoundError: No module named 'Cryptodome'

尝试安装Cryptodome,不对!

www:edm user$ pip3.6 install Cryptodome
Collecting Cryptodome
  Could not find a version that satisfies the requirement Cryptodome (from versions: )
No matching distribution found for Cryptodome
You are using pip version 9.0.1, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
www:edm user$ pip3.6 install --upgrade pip3.6
Collecting pip3.6
  Could not find a version that satisfies the requirement pip3.6 (from versions: )
No matching distribution found for pip3.6
You are using pip version 9.0.1, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

Google到了应该安装这个pycryptodomex,重新安装提示已经存:

www:edm user$ pip3.6 install pycryptodomex
Requirement already satisfied: pycryptodomex in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
You are using pip version 9.0.1, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

解决办法

进入site-packages 里面,发现存在两个不同版本的这个项目

drwxr-xr-x    7 www  admin     238  9  9  2017 pycryptodome-3.4.7-py3.6.egg-info
drwxr-xr-x    7 www  admin     238  9  9  2017 pycryptodomex-3.4.7-py3.6.egg-info

删除那些所有以这个开头的,然后在重新安装问题解决

cd /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
rm -rf pycryptodome*

遗留问题

但是为何之前OK的会突然报错不存在呢?

如果您有解答,欢迎交流 [email protected]

猜你喜欢

转载自blog.csdn.net/default7/article/details/80467634
今日推荐