I have my django project folder named myProjectName and in it I did python -m venv env
.
The env
folder is now close to a 900MB and we have a git pipeline that takes the backup of the entire myProjectName folder and stores it in S3 for every git push origin uat
.
Now I want the myProjectName folder not to contain the env folder.
If I move it to another location like ~/home
will the app still run if I do source ~/home/env/bin/activate
and run the server from myProjectName ?
I moved env folder to ~ and did source ~/env/bin/activate
which worked but on running python3 manage.py runserver
I’m getting
Traceback (most recent call last):
File "manage.py", line 11, in main
from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 22, in <module>
main()
File "manage.py", line 13, in main
raise ImportError(
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?
You can’t just pysically copy a venv from one location to another without a lot of work. You should build the venv in its new location.
Copying a venv would at least involve editing all of the scripts in the bin directory to point to their new location. (I’ve never done this, so I’m not immediately aware of everything that may need to be done for it.)
1 Like