-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Windows, activate_this assumes *nix path to site-packages #43
Comments
|
|
To get the ball rolling on this issue, I implemented and tested what I hope is NOTE: I only tested this on Windows XP (32bit) I have not tested it on Vista, Hope it helps.
|
Note I haven't tested this change myself, if it didn't fix the problem please
|
==== The problem
When I attempt to use the activate_this.py script to activate an environment on Windows, the script appears to have correctly reworked the python path through sys.path. However, I am unable to import any module installed to the virtualenv's site-packages.
==== The cause
I believe this is because the activate_this.py script assumes the path to the "site-packages" directory is the same on all platforms, but it is not. The location of the site-packages directory in virtualenvs on Windows is different from the location of the same directory on *nix type OSes.
On *nix type platforms, the location of site-packages is a directory on a path that is dependent on the Python version that was used to create the virtualenv.
So assuming the virtualenv was created with Python2.5, the activate_this.py script should use the location:
VIRTUALENV_BASE/lib/python2.5/site-packages/
On the other hand, with virtualenvs on Windows, the site-packages directory is located at:
*VIRTUALENV_BASE\Lib\site-packages*
==== Possible solution
I think this could be resolved with a simple check like:
==== Steps to re-create
Assumptions:
1. Create an isolated virtualenv and install a simple package in it:
2. Verify that you can import the module in the python shell when the virtualenv is activated with the batch file.
3. Create a python test script to activate the environment in python and import the "Yolk" module
Save the file as smalltest.py and try to run it.
IMPORTANT -- to recreate this issue properly, ensure that your virtualenv has been deactivated prior to running the smalltest.py script.
Observe that the import failed because the virtualenv was not properly activated by executing the activate_this.py script.
Local development environment:
If you are interested in how I discovered this problem, you may refer to :
The text was updated successfully, but these errors were encountered: