简体   繁体   English

python3如何自动安装模块?

[英]python3 how to install automatically module?

I try to install required module like this: 我尝试安装所需的模块,如下所示:

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')

As a result I get the following errors, how to make my code work? 结果出现以下错误,如何使代码正常工作?

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'

您有多个python版本吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM