简体   繁体   English

导入 py 文件错误:没有名为“文件名”的模块

[英]importing py file error: no module named 'filename'

Every time I import py files to my main py file, it gives每次我将 py 文件导入我的主 py 文件时,它都会给出

no module named没有模块命名

error.错误。

All are in the same folder.所有都在同一个文件夹中。
I am working on spyder environment.我正在研究 spyder 环境。 Both my python and spyder are in the same path, too:我的 python 和 spyder 也在同一条路径上:

C:\ProgramData\Anaconda3 C:\ProgramData\Anaconda3

I think you have to add yourpath to $PYTHONPATH or sys.path .我认为您必须将路径添加到$PYTHONPATHsys.path This might help How to fix "ImportError: No module named..." error in Python?这可能有助于如何修复 Python 中的“ImportError:No module named ...”错误?

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

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