简体   繁体   English

没有名为error python的模块,是否在sys.path上?

[英]no module named error python, is it on sys.path?

Okay, I am getting an error that is like no module named credentials 好的,我收到的错误就像没有模块命名凭据一样

http://i.imgur.com/g3VVhlL.png http://i.imgur.com/g3VVhlL.png

I have a credentials.py file in that directory. 我在该目录中有一个credentials.py文件。 I am sort of new to python and this is driving me nuts. 我对python有些新意,这让我疯狂。

How can I debug this, or can anyone tell right off the bat what may be the problem? 我怎样才能调试这个,或者任何人都可以直接告诉他们可能出现的问题?

When you do python keep_backend/manage.py runserver , then your PYTHONPATH will not include the current directory. 当您执行python keep_backend/manage.py runserver ,您的PYTHONPATH将不包含当前目录。 Instead, in will include the keep_backend directory. 相反,in将包含keep_backend目录。

Since credentials.py is in the current directory, it is not importable. 由于credentials.py位于当前目录中,因此无法导入。


A workaround is manually adding the right folder to your PYTHONPATH 解决方法是手动将正确的文件夹添加到PYTHONPATH

PYTHONPATH=`pwd`:$PYTHONPATH python keep_backend/manage.py runserver

But you should most likely rethink your directory structure here. 但是你最有可能在这里重新考虑你的目录结构。

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

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