如何在python中解决ModuleNotFoundError?

时间:2019-05-29 09:02:13

标签: python

我在Python 3.7.3中使用openbabel模块,该代码在pycharm IDE环境中运行良好。但是,当我尝试在终端(Windows)中执行python脚本时,该脚本不起作用并显示ModuleNotFoundError。

Traceback (most recent call last):
  File "C:\Users\com\PycharmProjects\base\docking\src\test.py", line 1, in <module>
    from openbabel import OBMol, OBConversion
ModuleNotFoundError: No module named 'openbabel' 

我想这个问题与sys.path有关。但是openbabel模块的路径保存在sys中。路径列表

from openbabel import OBMol, OBConversion
import sys

sys.path = list(set(sys.path))

for i in sys.path:
    print(i)

obmol = OBMol()
obconversion = OBConversion()
obconversion.GetInAndOutFormats("pdb", "pdbqt")

sys.path

['C:\\Users\\com\\Miniconda3\\envs\\ground\\lib', 'C:\\Users\\com\\Miniconda3\\envs\\ground\\DLLs', 'C:\\Users\\com\\Miniconda3\\envs\\ground\\lib\\site-packages', 'C:\\python27\\include', 
'C:\\Program Files\\JetBrains\\PyCharm Community Edition 2019.1.2\\helpers\\pydev', 'C:\\Users\\com\\Miniconda3\\envs\\ground\\python37.zip', 'C:/Users/com/PycharmProjects/base', 
'C:\\Program Files\\JetBrains\\PyCharm Community Edition 2019.1.2\\helpers\\third_party\\thriftpy', 'C:\\Users\\com\\Miniconda3\\envs\\ground', 'C:\\Users\\com\\PycharmProjects\\base']

openbabel.py路径:

"C:\Users\com\Miniconda3\envs\ground\lib\site-packages"

我不知道此问题的原因...我需要您的帮助。谢谢。

0 个答案:

没有答案