There are several ways to handle this.
Option 0
Allow access to global site packages from virtualenv. Pass the --system-site-packages virtualenv option when creating the virtual environment.
Or use the toggleglobalsitepackages command (from virtualenvwrapper ) to allow access to global site packages.
(test1)$ toggleglobalsitepackages Enabled global site-packages (test1)$ python -c "import pysvn; print 'ok'" ok (test1)$ toggleglobalsitepackages Disabled global site-packages (test1)$ python -c "import pysvn; print 'ok'" Traceback (most recent call last): File "<string>", line 1, in <module> ImportError: No module named pysvn
Option 1
Use easy_install to install the package in virtualenv using the binary installer. For example, on Windows, a process might look like this:
- Download the installation file. In this example, let it example_installer.msi (or example_installer.exe)
- Activate virtualenv (I use virtualenvwrapper-win on Windows)
easy_install example_installer.msi
Make sure you can install the installer throughout the site by double-clicking and running the installer in gui mode (then uninstal using the Windows Add / Remove Programs control panel). If you can install it on the site, then easy_install can probably install it in virtualenv.
However, the pysvn binary installer is not structured correctly for easy_install. If you try this using the Windows pysvn binary installer, you will get this error:
error: py27-pysvn-svn185-1.7.9-1572.exe is not a valid distutils Windows .exe
Option 2
Use the add2virtualenv command from virtualenvwrapper . This adds the .pth file to the virtualenv site-packages directory, which provides virtual access to the specified directories.
Note that you must specify a parent directory instead of a specific package. That is, instead of
add2virtualenv /usr/lib/python2.7/dist-packages/pysvn
It should be
add2virtualenv /usr/lib/python2.7/dist-packages
See this question: add2virtualenv (virtualenv wrapper) does not work with scipy
To find the directory where the package is installed, do the following:
$ python >>> import pysvn >>> pysvn.__file__ '/usr/lib/python2.7/dist-packages/pysvn/__init__.pyc'
The problem is that these are all packages in the specified directory, not just pysvn. Thus, it has the same drawback as toggleglobalsitepackages .
Option 3
Symlink install the directory into the virtual package sites.
A Convenient Way to Get a Directory of Virtual Sites - The virtualenvwrapper cdsitepackages
cdsitepackages ln -s /usr/lib/python2.7/dist-packages/pysvn pysvn
Summary
On Windows, try option 1 (easy_install from the binary installer). If this fails, install globally and allow virtualenv to access it using the virtualenvwrapper-win toggleglobalsitepackages or by passing the --system-site-packages option for virtualenv.
On systems that support symbolic binding, such as Linux and OS X, use option 3. It allows you to access the packages that are specific to you, preventing access to all global site packages.