Professional Documents
Culture Documents
Django Not Working After Moving Directory. Do I Have A Path/python Installation Issue?
Django Not Working After Moving Directory. Do I Have A Path/python Installation Issue?
Do I
have a path/Python installation issue?
Asked 3 years ago Active 1 year, 10 months ago Viewed 912 times
• Install a virtual environment in the directory containing the Django project folder
(not the directory containing manage.py - one level up from that) with python3 -m
venv <venv-name>
• Activate the virtual environment and install Django, Pillow, whatever I need for
the project.
I know I'm missing something because I thought the way virtual environments
worked was that you installed them locally and then as long as all of that
accompanied your project folder, everything would be a-okay. But everything stops
working when I move the directory, and if I move it back it works again.
Can anyone tell me what kind of issue I'm dealing with here based on this? Is this
just normal behavior and I just need to get used to not moving Django project
folders?
UPDATE: If I delete the virtual environment folder and re-install it once the folder is
in the new location everything seems to work fine. I guess it's some issue with the
creation of virtual environments and some kind of link to my Python installation? I
have no idea.
python django
@Juergen - Yes, e.g. I'll have Projects/my_project/my_project, where the contents of the
first my_project are only the virtualenv and my_project (which contains manage.py). So
I'm just moving the whole folder from Projects/ – user6806370 Nov 10 '17 at 20:39
Blind guess:
1 1) Did you activate your Virtual Environment? It sounds like manage.py couldn't find
the django installation.
3) Do you move the env itself? The generated activate -script has hardcoded (
mine: e.g. VIRTUAL_ENV="/home/thomas/Intevation/env" ) paths in it. I would
recommend to make a new env and install it there.
1 1) Haha, yes -- unfortunately I made that mistake earlier on but fortunately caught myself
before coming here for help. 2) Yes, the only two packages I install for this particular
project are django and Pillow – user6806370 Nov 10 '17 at 20:52
Okay the hard-coded paths in the activate script makes sense. Thanks very much! I'll
take a look at Pipenv! – user6806370 Nov 10 '17 at 21:08
Late response, but I want to apport my workaround for this issue. Thanks to the
Thomas response I understood the problem by looking at the activate script. So,
By 1
using our
wassite, you acknowledge
easier that youthe
in my case restore have read and
original understand
path ourthese
and follow Cookiesteps:
Policy, Privacy
Policy, and our Terms of Service.
1. Before to move the project and with the virtual environment activated
deactivate
rm -rf .env
By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy
Policy, and our Terms of Service.