13

is there any means of telling QGIS to use a different Python installation than the default, system-wide one? E.g. use some virtualenv Python /myvirtualenv/bin/python instead of /usr/bin/python?

Background: I'm developing a custom plugin that uses some modules which are only installed in a certain virtualenv, but not system-wide.

The virtualenv is allowed to access system-wide packages, so the qgis core libs should still be accessible when using that virtualenv.

The only solution that I see right now is to install the required modules in the system-wide Python. However, I'd like to keep them in the virtualenv only, if possible.

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Jan 27, 2015 at 12:43

2 Answers 2

7

You can first load your virtual environment and then start QGIS in the same terminal where you loaded the virtual environment.

for example in linux:

source /myvirtualenv/bin/activate
qgis
PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
answered Jan 29, 2015 at 10:21
2
  • 1
    this didn't work for me (QGIS 3.4.4, linux mint 18) Commented Jul 18, 2019 at 17:04
  • for my only worked if creating the virtual environment with python3 -m venv .venv --system-site-packages and then source .venv/bin/activate and qgis Commented Aug 29, 2024 at 20:30
3

I cannot guarantee this will work but perhaps you could try setting a custom variable to load your python version:

System Environment

answered Jan 27, 2015 at 12:52

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.