0
votes

UPDATE: NOTE THIS IS ON A WINDOWS MACHINE

There are numerous posts on stack about virtualenv and the differences in pythonpath of an install. In most cases, these users simply forget to activate the env before doing a pip install.

this is NOT my problem

Instead, my problem lies with django when running manage.py runserver. I am trying to migrate a django project that was started before I created a virtualenv. As part of this, I have attempted creating a new django project within an activated virtualenv and simply migrated my old files over.

(VENV) python django-admin.py startproject XYZ

*NOTE: I have already activated the virtualenv AND run the command with "python", which refers to the python installation within the virutalenv

I then migrate my old files over and run:

python manage.py runserver

At this point the DLL load fails.

Error: DLL load failed: The specified module could not be found.

Running a normal manage.py runserver works, but as this refers to the global python installation, that is not what I want.

1
Can you update the question with the complete traceback? - Burhan Khalid
That is it. Immediately after I run manage.py runserver, all it isays is Error: DLL load failed... ... This is a fresh python install on a windows machine, but I should note that the global manage.py runserver works properly - snakesNbronies
What database driver are you using? is it installed in the virtual environment, and what version of Python? - Burhan Khalid
@BurhanKhalid postgresql - I have already installed psycopg2 within the virtualenv, and even tried installing via easy_install as suggested by heroku devcenter.heroku.com/articles/psycopg2-windows - snakesNbronies
@BurhanKhalid I presume it's something in ~\Python27\\DLLs that the virtualenv python can't load in and of itself. trying to figure that out now. - snakesNbronies

1 Answers

0
votes

Binary installers on Windows for Python are not compatible with virtual environments and only install to the default system Python (as listed in the registry).

Therefore, packages such as database drivers and others like the Python Imaging Library are not compatible with virtual environments.

I know of three options:

  1. Set up the compiler environment and manually build your modules (not recommended).
  2. Use system Python (easier, and works with pre-built binary Windows packages for Python); and manage your requirements manually.
  3. Manually copy over the required files to your virtual environment.

I recommend #2 as the easiest of the three.

You can try and use setuptools (easy_install or pip), but unless you have setup a development environment the packages will not compile and install successfully (the DLLs will not be built); leading to errors like the one you experienced.

For heroku; you can manually manage your requirements file and add psycopg2 to make sure heroku deploys your application correctly.