snakesNbronies
snakesNbronies

Reputation: 3920

windows + virtualenv - django runserver searches global pythonpath

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.

Upvotes: 0

Views: 898

Answers (1)

Burhan Khalid
Burhan Khalid

Reputation: 174662

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.

Upvotes: 0

Related Questions