gpt4 book ai didi

Python 搜索路径 - python 找不到我的模块

转载 作者:行者123 更新时间:2023-11-28 20:10:31 25 4
gpt4 key购买 nike

我正在尝试从命令行运行脚本,而 python 完全没有:

[graffias:~/testing.tustincommercial.com]$ export PYTHONPATH=`pwd`:$PYTHONPATH                                          
[graffias:~/testing.tustincommercial.com]$ python -c 'import oneclickcos.mainapp; mainapp.mail.worker_loop()'
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named oneclickcos.mainapp
[graffias:~/testing.tustincommercial.com]$ python
Python 2.5.2 (r252:60911, Jan 24 2010, 17:44:40)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import oneclickcos
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named oneclickcos
>>>
[graffias:~/testing.tustincommercial.com]$ ls ./oneclickcos/mainapp/mail.py
./oneclickcos/mainapp/mail.py
[graffias:~/testing.tustincommercial.com]$

有什么想法吗?

粗心者请注意:上面的命令应该是$python -c 'import oneclickcos.mainapp.mail; oneclickcos.mainapp.mail.worker_loop()'(另一个有效变体)。

最佳答案

oneclickcos/oneclickcos/mainapp/ 中是否有__init__.py?如果不是,请放入一个并重试 — 这可能会导致您遇到的问题。

有关更多信息,请参阅 http://docs.python.org/tutorial/modules.html

关于Python 搜索路径 - python 找不到我的模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7081544/

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