CaffeineAddiction
CaffeineAddiction

Reputation: 823

ModuleNotFoundError: No module named 'script'

I have attempted to install PYAHK via pip install pyahk as well as 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

both of these error out with the following message:

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'

However ... the module in question .\ahk\script.py does in fact exist

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

is there a reason that a module cant be named script.py in python3? Did I miss something in the install?

Upvotes: 3

Views: 22320

Answers (1)

phd
phd

Reputation: 94483

from script import was a relative import in Python 2 but became an absolute import in Python 3; there is no global module 'script' hence the error. In Py3 it must be from ahk.script import or relative import from .script import.

Upvotes: 6

Related Questions