B
B
Babamurat2020-06-10 09:19:56
Python
Babamurat, 2020-06-10 09:19:56

How to specify the places where the python interpreter searches?

How to specify the places where the python interpreter searches?
I write modules and import them using import. But the interpreter looks for modules only from the folder in which the program itself is located. How to make the interpreter look for modules in other places?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Pankov, 2020-06-10
@trapwalker

In addition to the way indicated in the adjacent answer, there is another way to do this from the python program itself:

import sys

sys.path.append('some/custom/path/to/modules_and_packages_collection_folder')

B
BitNeBolt, 2020-06-10
@BitNeBolt

https://andreyex.ru/yazyk-programmirovaniya-python...


PYTHONPATH
It has the same PATH role. This variable tells the Python interpreter where to find the module files imported into the program. Must include the Python source library directory and directories containing the Python source code. PYTHONPATH is sometimes pre-set by the Python installer.

set PYTHONPATH="path"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question