Python Forum
ModuleNotFoundError: No module named 'athena_read'
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ModuleNotFoundError: No module named 'athena_read'
#1
I have file athena_read.py but i am still getting error ModuleNotFoundError: No module named 'athena_read' How can i overcome that err


Error:
   ~  cd ./Pictures/MikiForRaman  ✔    ~/Pictures/MikiForRaman  python m2c_read_athdata.py  ✔ /home/raman/Pictures/MikiForRaman/m2c_read_athdata.py:1: SyntaxWarning: invalid escape sequence '\d' """ /home/raman/Pictures/MikiForRaman/m2c_read_athdata.py:146: SyntaxWarning: invalid escape sequence '\m' ''' Traceback (most recent call last): File "/home/raman/Pictures/MikiForRaman/m2c_read_athdata.py", line 37, in <module> from pyfiles import read_athinput ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/raman/Pictures/MikiForRaman/pyfiles/__init__.py", line 3, in <module> from .unimesh import * File "/home/raman/Pictures/MikiForRaman/pyfiles/unimesh.py", line 15, in <module> import athena_read ModuleNotFoundError: No module named 'athena_read'    ~/Pi/MikiForRaman  cd ./pyfiles  1 ✘  3s     ~/Pi/M/pyfiles  ls  ✔ athena_read.py fm_torus.pyc metric.py read_athinput.py read_data.pyc athena_read.pyc __init__.py metric.pyc read_athinput.pyc unimesh.py fm_torus.py __init__.pyc __pycache__ read_data.py unimesh.pyc
Reply
#2
It sounds like a path issue. Make sure the directory containing athena_read.py is in your Python path. You can do this by modifying your PYTHONPATH environment variable or adding the path directly to your script. import sys sys.path.append('/home/raman/Pictures/MikiForRaman/pyfiles') import athena_read This should help Python locate the athena_read module. Hope this helps!
Reply
#3
I think your problem is the status of the pyfiles directory:
  • Is pyfiles just a directory containing Python modules that you want to import? In that case, it should not have an __init__.py file and it should be on the Python modules search path as @AdamHensley wrote above.
  • Or is pyfiles a Python package containing submodules? In that case unimesh.py should have from . import athena_read instead of import athena_read
In the first case, there are various ways to insert the directory in sys.path. One of them is to add to your site-packages directory a file with the .pth extension containing the path to your directory, for example
# in file mypythondirs.pth
/home/raman/Pictures/MikiForRaman/pyfiles
If you are using your system Python interpreter, you can put that file in the directory printed by the command python -c "import site; print(site.getusersitepackages())". If not, you can store it in one of the directories printed by python -c "import site; print(site.getsitepackages())"
« We can solve any problem by introducing an extra level of indirection »
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  no module named 'docx' when importing docx MaartenRo 1 1,366 Dec-31-2023, 11:21 AM
Last Post: deanhystad
  Problem with pymodbus - ModuleNotFoundError: No module named 'pymodbus.client.sync' stsxbel 2 25,017 Nov-02-2023, 08:20 AM
Last Post: South_east
  ModuleNotFoundError: No module named 'requests' Serg 18 3,497 Oct-29-2023, 11:33 PM
Last Post: Serg
  Resolving ImportError: No module named gdb (Python in C++) mandaxyz 3 1,829 Oct-04-2023, 02:43 PM
Last Post: mandaxyz
  ModuleNotFoundError: No module named 'PyPDF2' Benitta2525 1 1,900 Aug-07-2023, 05:32 AM
Last Post: DPaul
  ModuleNotFoundError: No module named 'eyed3' Wimpy_Wellington 2 1,685 Jul-10-2023, 03:37 AM
Last Post: Wimpy_Wellington
  How to fix this error: ModuleNotFoundError: No module named 'notears' yaoyao22 2 1,288 Jul-09-2023, 11:24 AM
Last Post: yaoyao22
  Help with pyinstaller "No module named" korenron 9 10,643 Jun-15-2023, 12:20 PM
Last Post: snippsat
  Problem with Pyinstaller. No module named '_tkinter' tonynapoli2309 0 1,165 May-15-2023, 02:38 PM
Last Post: tonynapoli2309
  ModuleNotFoundError: No module named 'omsdk.sdkproto' donvito7 4 2,116 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