0

Here is my package structure:

upgradehost
    |
    |_ _ upgradehost
    |   |
    |   |_ app.py 
    |   |
    |   |_ core.py
    |   |
    |   |_ stable.py
    |   |
    |   |_ __init__.py
    |
    |_ _ doc
    |
    |_ _ test
    |
    |_ _ setup.py
    |
    |_ _ __init__.py

My app.py contains following import:

from core import customlogger, upgradeHost  
from stable import vm_upgarde, disk_upgrade

My setup.py conains the following as parameters to setuptools.setup()

packages=['upgradehost'],
py_modules=['upgradehost.core', 'upgradehost.stable'],  # I added this after getting the "ModuleNotFoundError: No module named 'core'" the first time.

Then I tried to install the package.

> python setup.py install

creating build\bdist.win32\egg\upgradehost
copying build\lib\upgradehost\1.py -> build\bdist.win32\egg\upgradehost
copying build\lib\upgradehost\app.py -> build\bdist.win32\egg\upgradehost
copying build\lib\upgradehost\core.py -> build\bdist.win32\egg\upgradehost
copying build\lib\upgradehost\stable.py -> build\bdist.win32\egg\upgradehost
copying build\lib\upgradehost\__init__.py -> build\bdist.win32\egg\upgradehost
.
.
.
byte-compiling build\bdist.win32\egg\upgradehost\app.py to app.cpython-38.pyc
byte-compiling build\bdist.win32\egg\upgradehost\core.py to core.cpython-38.pyc
byte-compiling build\bdist.win32\egg\upgradehost\stable.py to stable.cpython-38.pyc
.
.
.
Installed c:\users\may\appdata\local\programs\python\python38-32\lib\site-packages\upgradehost-0.0.1-py3.8.egg
Processing dependencies for upgradehost==0.0.1
Finished processing dependencies for upgradehost==0.0.1

Then I try to run the application from the \Python\Python38-32\Scripts directory.

> upgradehost -h 

Traceback (most recent call last):
  File "C:\Users\may\AppData\Local\Programs\Python\Python38-32\Scripts\upgradehost-script.py", line 11, in <module>
    load_entry_point('upgradehost==0.0.1', 'console_scripts', 'upgradehost')()
  File "C:\Users\may\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pkg_resources\__init__.py", line 489, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "C:\Users\may\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pkg_resources\__init__.py", line 2852, in load_entry_point
    return ep.load()
  File "C:\Users\may\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pkg_resources\__init__.py", line 2443, in load
    return self.resolve()
  File "C:\Users\may\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pkg_resources\__init__.py", line 2449, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "<frozen zipimport>", line 259, in load_module
  File "C:\Users\may\AppData\Local\Programs\Python\Python38-32\lib\site-packages\upgradehost-0.0.1-py3.8.egg\upgradehost\app.py", line 6, in <module>
ModuleNotFoundError: No module named 'core'

I need your kind help to let me know what is happening here and how this can be resolved. I am on Windows 10 and Python 3.8

May
  • 1,158
  • 2
  • 13
  • 24
  • Which of the directories, if any, are in `sys.path`? – John Gordon Jul 31 '20 at 01:35
  • Hi John, Thanks for your time. I resolved the error by doing 2 things: In the app.py file I put the full path of module. I changed "from core import customlogger, upgradeHost " to "from "upgradehost.core import customlogger, upgradeHost" .. The next change I did was changing packages=['upgradehost'] to packages=setuptools.find_packages() ... I followed the suggestion from here: https://stackoverflow.com/questions/59305504/modulenotfounderror-no-module-named-modulename-after-pip-install – May Jul 31 '20 at 01:48

0 Answers0