[英]Can't open file 'menu.py': [Errno 2] No such file or directory
I have created a virtual environment in python3.5 and I've created many programs in that environment. 我在python3.5中创建了一个虚拟环境,并在该环境中创建了许多程序。
I activated the environment and executed one of my python programs using shell scripting ( .sh
file). 我激活了环境,并使用Shell脚本( .sh
文件)执行了我的python程序之一。
In that program, I have imported another program which is in the same env, but when I run the program I am not able to import it, and I get this error: 在该程序中,我导入了另一个在同一环境中的程序,但是当我运行该程序时,无法导入它,并且出现此错误:
Can't open file 'menu.py': [Errno 2] No such file or directory
As others said it is a bit difficult to determine your current setup but I think you need to add your root directory of your source code to PYTHONPATH. 正如其他人所说,确定当前设置有些困难,但是我认为您需要将源代码的根目录添加到PYTHONPATH中。 Use this: 用这个:
PYTHONPATH=/absolute/path/to/root python3 menu.py
谢谢你的评论.....我调试了错误。问题是当我在主程序中导入其他py文件时,我没有在主程序中提及其他程序的路径...但是感谢支撑...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.