python3如何自动安装模块?

时间:2019-07-19 11:59:16

标签: python

我尝试这样安装所需的模块:

try:
    import pyAesCrypt

    print('package: pyAesCrypt found')
except:
    mod_inst = subprocess.Popen("pip3  install pyAesCrypt", shell=True) 
    mod_inst.wait()

    import pyAesCrypt
    print('package: ' + package + ' installed')

结果是出现以下错误,如何使代码正常工作?

Collecting pyAesCrypt
  Using cached https://files.pythonhosted.org/packages/c5/99/ebae89da08a443d0191eff631d66b71955eec7e370e2a309d85e499ca18a/pyAesCrypt-0.4.3-py3-none-any.whl
Requirement already satisfied: cryptography in /usr/lib/python3/dist-packages (from pyAesCrypt) (2.6.1)
Installing collected packages: pyAesCrypt
Successfully installed pyAesCrypt-0.4.3
Traceback (most recent call last):
  File "smb.py", line 6, in <module>
    import pyAesCrypt
ModuleNotFoundError: No module named 'pyAesCrypt'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "smb.py", line 13, in <module>
    import pyAesCrypt
ModuleNotFoundError: No module named 'pyAesCrypt'

1 个答案:

答案 0 :(得分:0)

您有多个python版本吗?

相关问题