我搜索了很多关于ImportError: No module named
错误的讨论,但是似乎没有人能解决我的问题,所以请允许我再次询问。在
以下是我的包文件夹结构:
/modules
├── build
│ ├── lib.linux-x86_64-2.7
│ │ └── Package
│ │ ├── __init__.so
│ │ ├── SendTraffic.so
│ │ └── Utils.so
│ └── temp.linux-x86_64-2.7
│ └── Package
│ ├── __init__.o
│ ├── SendTraffic.o
│ └── Utils.o
├── Package
│ ├── __init__.py
│ ├── SendTraffic.c
│ ├── SendTraffic.py
│ ├── SendTraffic.pyc
│ ├── Utils.c
│ ├── Utils.py
│ └── Utils.pyc
├── setup.py
以及设置.py在
^{pr2}$它可以成功地生成.so文件。但是当我在/modules/build/lib.linux-x86_64-2.7
下导入它们时:
/modules/build/lib.linux-x86_64-2.7$ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import Package.SendTraffic
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named Package.SendTraffic
在包文件夹中,我可以成功导入它们:
/modules/build/lib.linux-x86_64-2.7/Package$ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import SendTraffic
>>>
我也尝试过将/modules/build/lib.linux-x86_64-2.7
添加到搜索路径,但不起作用。使用setup.py install
将它们安装到系统范围的包文件夹中也不起作用。在
有人能帮我进口吗Package.SendTraffic成功了吗?在
我终于找到了答案。在
在包文件夹中,
__init__.so
不被python接受,它需要__init__.py
文件相关问题 更多 >
编程相关推荐