简体   繁体   English

无法打开文件'menu.py':[Errno 2]没有这样的文件或目录

[英]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.

相关问题 无法打开文件'file.py':[Errno 2] 没有这样的文件或目录 - Can't open file 'file.py': [Errno 2] No such file or directory 无法打开文件“import.py”:[Errno 2] 没有这样的文件或目录 - can't open file 'import.py' :[Errno 2] No such file or directory 无法打开文件 'main.py': [Errno 2] 没有那个文件或目录 - Can't open file 'main.py': [Errno 2] No such file or directory 无法打开文件 'app.py': [Errno 2] 没有那个文件或目录 - can't open file 'app.py': [Errno 2] No such file or directory 无法打开文件'.manage.py':[Errno 2] 没有这样的文件或目录 - can't open file '.manage.py': [Errno 2] No such file or directory 无法打开文件“audioAnalysis.py”:[Errno 2] 没有这样的文件或目录 - Can't open file 'audioAnalysis.py': [Errno 2] No such file or directory 无法打开文件 'manage.py': [Errno 2] 没有那个文件或目录 - Can't open file 'manage.py': [Errno 2] No such file or directory 找不到 >python scraper.py - 无法打开文件“scraper.py”:[Errno 2] 没有这样的文件或目录 - Cant find >python scraper.py - can't open file 'scraper.py': [Errno 2] No such file or directory 无法打开文件:[Errno 2] 没有那个文件或目录 - can't open file : [Errno 2] No such file or directory 无法打开文件 [Errno 2] 没有这样的文件或目录 - Can't Open File [Errno 2 ] No such file or directory
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM