1
votes

I am trying to run a python script inside another one. Therefore, I want to activate the second virtual environment by calling its python executable. In fact, I want to call:

/home/mmoradi2/.local/share/virtualenvs/myproject-d4CrnaVY/bin/python3   second_tool.py  -t table1 .....

In order to find the correct python executable, first I activated the virtual environment of the second tool by pipenv shell. Then, I did it:

$python3
import sys
sys.executable

And the result is like this:

'/home/mmoradi2/.local/share/virtualenvs/myproject-d4CrnaVY/bin/python3'

Then, I went to that directory by:

$cd /home/mmoradi2/.local/share/virtualenvs/myproject-d4CrnaVY/bin

Then, I run python by "python3".

This way, when I try to import the packages of the project, it does not recongnize them!!

when I activate the virtual environment by pipenv shell then I call python3, it recongnize those packages. But when I call python executable from the directory of virtual environment it does not recognize them. What should I do?

1

1 Answers

0
votes

I found the problem. I should use the full path of the python executable. It is not working by navigating to the directory and then calling python! } maybe even if you navigate to the folder of python executable still you are calling the default python that is added to path variables.

Thus, when I use this line it runs python and this python recognizes the packages that exist in the virtual environment:

/home/mmoradi2/.local/share/virtualenvs/myproject-d4CrnaVY/bin/python3