Ubuntu: Python Virtual Environment - sys.path

Question:

The python packages are installed by using apt and not by some other source such as pip to do the virtual environment. The same code is running in a Windows environment. So it seems to me an OS issue rather than a python issue. It does not find any library I install using pip within the virtual environment. I did the following steps:

I removed all packages and reinstalled it. Do now use Python 3.5, however it didn't help.

Solution:1

Seems you are using #!/usr/bin/python3 in head of your script. This tells bash to execute script with /usr/bin/python3, which might not be the same as python. When using virtual environment this is almost certainly not true. You can check which python is ran in venv with $ which python

As a solution, try deleting first line and execute script as $ python testDB.py or, if you need to run it as script, replace first line with #!python.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com