TaiwanGrapefruitTea
TaiwanGrapefruitTea

Reputation: 1245

on Windows, virtualenv is not being used with i run a python program

I have virtualenv installed on windows.

In cmd, i run python and look at sys.path and see the virtualenv path included.

but when i run manage.py (for django), I don't see the virtualenv path, so virtualenv is not working with django server.

Why?

Upvotes: 2

Views: 663

Answers (3)

TaiwanGrapefruitTea
TaiwanGrapefruitTea

Reputation: 1245

the solution is to explicitly invoke python by using: python file.py

as described in http://www.velocityreviews.com/forums/t727997-problems-running-virtualenv-under-windows.html

for some reason, the python registered with .py in windows does not invoke virtualenv.

Upvotes: 3

ᅠᅠᅠ
ᅠᅠᅠ

Reputation: 67040

Virtualenv modifies the PATH to include a Python with the correct setup. It's a completely separate program from the system Python.

The PATH is used to look up programs by name: the first program of a given name that's in the PATH gets executed.

When you “run a file”, Windows uses the extension of the file to look up a program to run. It doesn't look it up by the name of the program, and so doesn't check the PATH.

The solution is to explicitly invoke Python from the command line (python manage.py) while a virtualenv is active. This way, Windows will search PATH for what you meant by “python”, and find the correct one.

Upvotes: 1

Anentropic
Anentropic

Reputation: 33923

have you done:

> source ../path-to/bin/activate

?

Upvotes: 0

Related Questions