即使我的路径看起来正确,我也无法导入模块。
>>> import cms.middleware.page
Traceback (most recent call last):
File "<console>", line 1, in <module>
ImportError: No module named middleware.page
Heres显示我的路径没问题
>>> for x in sys.path:
... if x == "/usr/local/lib/python2.7/site-packages":
... print x
...
/usr/local/lib/python2.7/site-packages
这是模块
[root@monty codecrab]# ls -l /usr/local/lib/python2.7/site-packages/cms/middleware/page.py
-rw-r--r-- 1 root root 1304 Apr 17 19:49 /usr/local/lib/python2.7/site-packages/cms/middleware/page.py
这是文件
[root@monty cms]# pwd
/usr/local/lib/python2.7/site-packages/cms
[root@monty cms]# ls -l __init__.py middleware/__init__.py middleware/page.py
-rw-r--r-- 1 root root 47 Apr 17 19:49 __init__.py
-rw-r--r-- 1 root root 0 Apr 17 19:49 middleware/__init__.py
-rw-r--r-- 1 root root 1304 Apr 17 19:49 middleware/page.py
有任何想法吗 ?