Home > Mobile >  How to get module from another directory from terminal?
How to get module from another directory from terminal?

Time:03-08

this is in Python, python 3.10.2 if we need specifics.

I’m using the Mac Terminal and I want to access a folder from it

I have a folder on my desktop that has a bunch of my modules. I wanna access these from the terminal in a style like: “import module” with using some command to get to that folder.

Help would be appreciated!

CodePudding user response:

You can import sys, then sys.path.append(path_to_desired_modules). sys.path is a list of the directories where Python will search for the modules to import, so if you append the target directory to that, it should be retrievable.

  • Related