Python Forum
problem in import module from other folder
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
problem in import module from other folder
#6
(Sep-01-2023, 05:47 AM)Pedroski55 Wrote: I don't add the path permanently to $PATH because I don't use them very frequently.
Dont mistake the Module Search Path with the environment variable $PATH, they are completely different things.

What you could do is put them in a package that would be permanently available for example
Output:
myPython └── packages └── infrequent ├── __init__.py # add this file to make infrequent a package (an empty file suffices) ├── score_oralsOMR.py └── ... others.py
Then you permanently add '/home/pedro/myPython/packages/' to sys.path by editing your usercustomize.py module for example, then you can write in your scripts
from infrequent import score_oralsOMR
As for module usercustomize, if it doesn't already exist, create usercustomize.py in the directory returned by the command
Output:
python -c "import site; print(site.getusersitepackages())"
In usercustomize.py, add the lines
import site
site.addsitedir('/home/pedro/myPython/packages')
Reply


Messages In This Thread
RE: problem in import module from other folder - by Gribouillis - Sep-01-2023, 07:48 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  problem with memory_graph module akbarza 3 464 Mar-04-2024, 10:15 AM
Last Post: snippsat
  problem using coloeama module akbarza 3 670 Jan-08-2024, 07:31 AM
Last Post: akbarza
  Compare folder A and subfolder B and display files that are in folder A but not in su Melcu54 3 668 Jan-05-2024, 05:16 PM
Last Post: Pedroski55
  is import cointegration_analysis a recognized module mitcht33 1 503 Nov-06-2023, 09:29 PM
Last Post: deanhystad
  problem in using subprocess module akbarza 5 1,153 Sep-24-2023, 02:02 PM
Last Post: snippsat
  problem in using pyqrcode module to create QRcode akbarza 9 2,265 Aug-23-2023, 04:17 PM
Last Post: snippsat
  can not import anaconda pandas module. PySpark pandas module is imported!! aupres 0 775 Aug-06-2023, 01:09 AM
Last Post: aupres
  [WORKED AROUND] Problem installing elitech-datareader, 'cannot import build_py_2to3' NeilUK 4 1,869 Jul-09-2023, 10:01 AM
Last Post: NeilUK
  Problem with Pyinstaller. No module named '_tkinter' tonynapoli2309 0 1,094 May-15-2023, 02:38 PM
Last Post: tonynapoli2309
  import module error tantony 5 3,616 Dec-15-2022, 01:55 PM
Last Post: Lauraburmrs

Forum Jump:

User Panel Messages

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