我在virtualenv建立一个项目:
py-procr/
procr/
bin/
lib/
include/
core/
pcp.py
__init__.py
tests/
__init__.py
runner.py
在初级保健医生公司名称:
^{pr2}$在跑步者.py公司名称:
^{3}$这是运行模式:
(procr)a@s ~/spaces/python/py-procr $ python procr/core/pcp.py
Main!
(procr)a@s ~/spaces/python/py-procr $ python tests/runner.py
Traceback (most recent call last):
File "tests/runner.py", line 2, in <module>
from procr.core.pcp import *
ImportError: No module named 'procr' ;; also 'core' and 'pcp' if you cut the import statement
(procr)a@s ~/spaces/python/py-procr $ python
Python 3.4.2 (default, Oct 8 2014, 13:44:52)
[GCC 4.9.1 20140903 (prerelease)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import procr.core.pcp
>>> import tests.runner ;; runner.py: from procr.core.pcp import *
>>> import tests.runner ;; runner.py: from core.pcp import *
>>> import tests.runner ;; runner.py: from pcp import *
>>> import core.pcp
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'core'
我的Python路径:
>>> sys.path
['', '/home/alexey/spaces/python/py-procr/procr/lib/python34.zip', '/home/alexey/spaces/python/py-procr/procr/lib/python3.4', '/home/alexey/spaces/python/py-procr/procr/lib/python3.4/plat-linux', '/home/alexey/spaces/python/py-procr/procr/lib/python3.4/lib-dynload', '/usr/lib64/python3.4', '/usr/lib/python3.4', '/usr/lib/python3.4/plat-linux', '/home/alexey/spaces/python/py-procr/procr/lib/python3.4/site-packages']
>>>
所以IDE/compiler(Eric)很高兴;pythonrepl也很高兴,但是我不能运行我的测试。在
尝试使用-m选项运行代码:
原因在PEP 338中解释:
这里还有一些答案:What is the -m switch for in Python?
相关问题 更多 >
编程相关推荐