Sunday, October 31, 2021

[SOLVED] When activating virtualenv still global dependencies are installed

Issue

I am having issues with virtualenv installations on a mac.

First change to the directory and activate virtualenv

cd my-project/
virtualenv venv
source venv/bin/activate

Second...my terminal changes to the virtualenv and install Django version 3.1.7

(venv) andrescamino@Robertos-MacBook-Pro WJKTM % pip install Django==3.1.7

To make sure the installation is on the virtualenv i make a pip freeze and these are the results

(venv) andrescamino@Robertos-MacBook-Pro WJKTM % pip freeze
asgiref==3.3.1
Django==3.1.7
pytz==2021.1
sqlparse==0.4.1

Then I start the project

(venv) andrescamino@Robertos-MacBook-Pro WJKTM % django-admin startproject bandsite

However when I go to the editor and check the settings file...it still shows the version installed globally which is the 3.1.2

Generated by 'django-admin startproject' using Django 3.1.2.

Am i missing something?


Solution

That's because vscode is using your global python installation. You can see and change which python environement vscode uses from the status bar in the bottom.



Answered By - Badredine Kheddaoui