Python (Windows Server) Virtualenv not recognizing Django is installed
For what it's worth - here is the solution and explanation:
Everything works as expected as was outlined in the question - the reason that the actual python command wasn't working had to do with a line in the .bashrc file.
There was an alias in the .bashrc file to set python to the command winpty C:\Python37\python
So when the command python manage.py collectstatic was getting ran - it was looking at the Python executable in the Python37 directory and not the virtualenvironment Python.
This was solved by simply running the appropriate Python (e.g.)
C:/my_project/venv/Scripts/python manage.py collectstatic
This forced it to use the virtualenvironment python to run the command so everything worked as expected.
My virtual environment refuses to recognize my install of Django (strangely)
I'm on Windows Server, installed Python 3.7 to a directory (C:\Python37) which I have C:\Python37;C:\Python37\Scripts in my windows Path so when using Powershell or GitBash I can use the python command.
if I run where python it shows the default install
I CD into my django project directory and run:
python virtualenv venv and the venv directory is created
Then I run source venv/Scripts/activate and it activates appropriately.
When I run where python it shows the exe inside the venv directory - which is expected and appropriate.
I run pip install -r requirements.txt and all my requirements install appropriately. I confirm they are installed with pip freeze (all installed correctly)
Once I do that I go to run python manage.py collectstatic (no migrations are required in this particular instance) I get an error message that Django isn't installed.
To check this, with my virtualenv still activated I enter the shell (python)
If I do import django it also says Django is not installed.
I cannot figure out what's happening here - the python version appears to be correct, the correct virtualenv is activated - but it's still not seeing the properly installed Django installation.
Thoughts? Ideas?