gpt4 book ai didi

Python - "No module named my_module"在终端中,但在 PyCharm 中不存在

转载 作者:太空宇宙 更新时间:2023-11-03 11:17:58 27 4
gpt4 key购买 nike

我有一个要运行的 Python 脚本。当我从 PyCharm 中运行它时它运行没有问题,但是当我通过终端运行它时使用:

python my_script.py

我得到:

Traceback (most recent call last):
File "folder/folder/my_script.py", line 4, in <module>
from my_module import me1, me2, me3
ImportError: No module named my_module

可能是什么问题?

最佳答案

您终端环境中的 PYTHONPATH 不包含“my_module”。

Configure the PYTHONPATH to include the directory containing your module

它在 pycharm 中工作,因为它会自动为您设置路径。

Learn about the module search path

关于Python - "No module named my_module"在终端中,但在 PyCharm 中不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48554693/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com