K
K
KirSupi2021-07-19 19:00:10
Python
KirSupi, 2021-07-19 19:00:10

How to change sys.path in venv?

Python in venv is not looking for modules in the right folders
To get python to look for them, I do the following:

import sys
sys.path.append('/pathtofolder/')

Is it possible to somehow change sys.path so that it does not have to be changed in each script during execution?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vindicar, 2021-07-19
@Vindicar

What are the modules?
If they are pip packages, they need to be installed to that particular venv using local pip.
If these are your own modules that you use often, you can try to create your own package and install it like any other. The package does not need to be downloaded by pypi.org, pip installs packages from a file just fine.
If these are local project modules, then you need to look at the directory structure of this project.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question