无法在自定义环境中导入python模块

时间:2020-05-08 14:52:52

标签: python python-import

我正在尝试在自定义python环境中导入PyQt5模块,但失败。 我已经使用系统python测试了它,并且工作正常

juan@juansphd:~/blender-2.82a-linux64/2.82/python/bin$ python3
Python 3.6.9 (default, Apr 18 2020, 01:56:04)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyQt5.QtCore
>>>

但是当我运行自定义环境的python3时,它无法加载

juan@juansphd:~/blender-2.82a-linux64/2.82/python/bin$ ./python3.7m
Python 3.7.4 (default, Oct  8 2019, 15:23:02)
[GCC 6.3.1 20170216 (Red Hat 6.3.1-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyQt5.QtCore
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'PyQt5'
>>>

我尝试将安装了PyQt5的/usr/lib/python3/dist-packages添加到sys.path中,但都不起作用

>>> sys.path.append("/usr/lib/python3/dist-packages")
>>> import PyQt5.QtCore
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'PyQt5.QtCore'
>>>

我应该如何导入模块?

0 个答案:

没有答案