Django not recognized in virtual environment altough already installed when inside virtual environment

I've created a virtual environment in my PC(Windows). I've pushed the project to my git repository and now cloned it into my Mac. I activated the virtual environment, and tried running :

python3 manage.py runserver

This error is raised :

ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?

I understand that the message sent from above is defined inside the manage.py if an ImportError is raised.

What I'm trying to understand is how to make the virtual environment to include the python packages inside my project. I will explain what I've tried doing below.

AFTER cloning the project, I've changed line in my :

pyvenv.cfg

...
include-system-site-packages = true
//previously = false
...

I'm not sure what I did wrong while setting up the virtual environment and installing the packages while being IN the virtual environment.

In your windows pc, inside the activated virtual environment, run

pip freeze > requirements.txt

Add this file to your git and push it to your repository.

After that, in your mac environment, pull the latest git changes and inside the activated virtual environment, run:

pip3 install -r requirements.txt

If pip3 is not recognized, use pip

Finally, run python3 manage.py runserver

Back to Top