问题描述
我真的是Python新手.我正在尝试导入名为primes.py的第三方模块.我已将此模块放置在C:\ Python26 \ Lib(安装Python的位置)中.然后,我有另一个文件正在尝试导入此模块.尝试导入素数的文件位于C:\ Python26.
I'm really new to Python. I'm trying to import a third party module called primes.py. I have placed this module in C:\Python26\Lib (the location where I installed Python). I then have another file which is trying to import this module. The file attempting to import primes is located at C:\Python26.
在我的Python文件中,我有以下两行:
In my Python file I have the following two lines:
import primes
import sys
运行此文件时,出现以下错误:
When I run this file, I get the following error:
ImportError: No module named primes
有人可以帮我吗?
推荐答案
将primes.py放入lib/site-packages/
目录.
Put primes.py in the lib/site-packages/
directory.
也:无需将自己的Python文件放在安装目录下:我建议您将它们放在其他地方(有意义的地方).
Also: no need to put your own Python files under the installation directory: I'd advise you to put them somewhere else (where it makes sense).
这篇关于python ImportError:没有名为primes的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!