Python 3 -“ImportError:没有命名的模块…”

时间:2021-12-23 04:58:33

I'm getting an error ImportError: No module named core.text
I'm using 'ActivePython-3.2.2.3-win64-x64' Actually, it was working fine in 32-bit win7. But recently, I have installed 64-bit win7. And now when I'm trying to run the same file again, it gives me an error. My directory structure:

我犯了一个错误:没有命名为core的模块。我使用的是“activepython3.2.2.3 -win64-x64”,它在32位win7中运行良好。但是最近,我安装了64位win7。现在,当我再次尝试运行相同的文件时,它会给我一个错误。我的目录结构:

my_SQLi.py
core
   text.py

So, I am clueless at this moment. Why it's throwing an error!!! Where and what changes I should make?

所以,我现在是一无所知。为什么它会抛出一个错误!!!我应该在哪里做什么改变?

1 个解决方案

#1


6  

You need to have a __init__.py file inside the core directory: this makes it a package, meaning you can access sub-modules with the "dotted" syntax core.text. The __init__.py file can be empty.

你需要有一个__init__。核心目录内的py文件:这使它成为一个包,这意味着您可以使用“点”语法内核来访问子模块。__init__。py文件可以是空的。

Reference: http://docs.python.org/3.3/tutorial/modules.html#packages

参考:http://docs.python.org/3.3/tutorial/modules.html包

#1


6  

You need to have a __init__.py file inside the core directory: this makes it a package, meaning you can access sub-modules with the "dotted" syntax core.text. The __init__.py file can be empty.

你需要有一个__init__。核心目录内的py文件:这使它成为一个包,这意味着您可以使用“点”语法内核来访问子模块。__init__。py文件可以是空的。

Reference: http://docs.python.org/3.3/tutorial/modules.html#packages

参考:http://docs.python.org/3.3/tutorial/modules.html包