Python Forum
ModuleNotFoundError: No module named ‘…’
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ModuleNotFoundError: No module named ‘…’
#1
Video 
Running outside Pycharm I always get an error.

I want to be able to run the module in:
  • Venv
    Pycharm terminal
    Windows Command Line
    Jenkins
    or whatever

I looked at paths, pythonpaths, packages, modules, imports relative/absolute. It is driving me crazy and I just don’t get it.

Inside Pycharm IDE it runs as expected.

C:\Data\Experiment>C:\Data\Experiment\module\ConsumerModule\consumer.py
Traceback (most recent call last):
File "C:\Data\Experiment\module\ConsumerModule\consumer.py", line 1, in <module>
from HelperModules.use_me import returnfunction
ModuleNotFoundError: No module named 'HelperModules'

The code is a simple. Don't say put the "use_me" module in the ConsumerModule folder. I get that. I want to structure hundreds of modules in separate folders for structuring a huge project.

Project
--ConsumerModule
----Consumer.py
------from HelperModules.use_me import returnfunction


------def test():
------str = returnfunction()
------print (str)

------if __name__ == '__main__':
------test()

--HelperModules
----use_me
------__init__.py

--------def returnfunction():
--------return 'from returnfunction'
Larz60+ write Dec-11-2020, 01:16 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Reply
#2
Not, sure, but like other IDEs it might run a bundled version of python installed with it and not the python version you installed separately.

Take a quick look through the options in pycharm and see if you can switch it.

The other route would be to use pip in the system command prompt to install the libraries you want into the version too.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  no module named 'docx' when importing docx MaartenRo 1 852 Dec-31-2023, 11:21 AM
Last Post: deanhystad
  Problem with pymodbus - ModuleNotFoundError: No module named 'pymodbus.client.sync' stsxbel 2 23,623 Nov-02-2023, 08:20 AM
Last Post: South_east
  ModuleNotFoundError: No module named 'requests' Serg 18 2,519 Oct-29-2023, 11:33 PM
Last Post: Serg
  Resolving ImportError: No module named gdb (Python in C++) mandaxyz 3 1,421 Oct-04-2023, 02:43 PM
Last Post: mandaxyz
  ModuleNotFoundError: No module named 'PyPDF2' Benitta2525 1 1,483 Aug-07-2023, 05:32 AM
Last Post: DPaul
  ModuleNotFoundError: No module named 'eyed3' Wimpy_Wellington 2 1,311 Jul-10-2023, 03:37 AM
Last Post: Wimpy_Wellington
  How to fix this error: ModuleNotFoundError: No module named 'notears' yaoyao22 2 1,020 Jul-09-2023, 11:24 AM
Last Post: yaoyao22
  Help with pyinstaller "No module named" korenron 9 8,898 Jun-15-2023, 12:20 PM
Last Post: snippsat
  Problem with Pyinstaller. No module named '_tkinter' tonynapoli2309 0 995 May-15-2023, 02:38 PM
Last Post: tonynapoli2309
  ModuleNotFoundError: No module named 'omsdk.sdkproto' donvito7 4 1,829 Oct-20-2022, 02:56 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020