我试图通过和安装PYAHKpip install pyahk``python setup.py install
pip install pyahk``python setup.py install
# pip --version pip 9.0.1 from c:\python36\lib\site-packages (python 3.6) # python --version Python 3.6.1
这两个错误均显示以下消息:
Traceback (most recent call last): File "<string>", line 1, in <module> File "C:\Users\ca\AppData\Local\Temp\pip-build-as2lv10i\pyahk\setup.py", line 3, in <module> import ahk File "C:\Users\ca\AppData\Local\Temp\pip-build-as2lv10i\pyahk\ahk\__init__.py", line 7, in <module> from script import Function, Script ModuleNotFoundError: No module named 'script'
但是…所讨论的模块.\ahk\script.py实际上确实存在
.\ahk\script.py
PYAHK │ .hgignore │ .hgtags │ .hg_archival.txt │ LICENSE.txt │ pylintrc │ README.rst │ runtests.py │ setup.py │ __init__.py │ ├───ahk │ │ ahk.py │ │ control.py │ │ script.py │ │ __init__.py │ │ │ └───__pycache__ │ __init__.cpython-36.pyc │ ├───doc │ │ ahk.rst │ │ conf.py │ │ control.rst │ │ index.rst │ │ make.bat │ │ script.rst │ │ │ └───_templates │ layout.html │ └───test test_ahk.py test_control.py test_script.py __init__.py
有模块无法script.py在python3中命名的原因吗?我在安装过程中错过了什么吗?
script.py
from script import在Python 2中是相对导入,但在Python 3中成为绝对导入;没有全局模块“脚本”,因此错误。在Py3中,它必须是from ahk.script import或相对导入from .script import。
from script import
from ahk.script import
from .script import