Rolando
Rolando

Reputation: 62664

How to import python-mysql package not installed in virtualenvironment?

I installed python-mysql using the following: http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python

The issue is on install, I have only the option to pick my root python install C:\Python27 and no virtualenvironment.

When I create my virtualenv "testenv", it does not have the "python-mysql" package installed. How can I make it such that "testenv" can access the "python-mysql" installed outside of my environment using the installer from the link above?

I am running Windows 7.

Upvotes: 0

Views: 66

Answers (3)

Alexey Stankevich
Alexey Stankevich

Reputation: 126

If you need to access module that isn't in current path, you can simply use this snippet before import:

import sys
sys.path.append("<path to you module>")

Upvotes: 0

Andrew Wilkinson
Andrew Wilkinson

Reputation: 10846

If you create your virtual environment as below you will have access to the main Python packages.

virtualenv --system-site-packages ENV

It is usual to install all your packages inside the virtual environment. To do this you need to use pip or easy_install.

Upvotes: 1

Luis Masuelli
Luis Masuelli

Reputation: 12343

Had the same issue, and solved it manually moving the created files to my virtualenv. Watch out since it also compiles extensions. Move all the recent files/folders once you install it, to the virtualenv (i.e. If the only package/folder you installed is that, in a certain period, move all the files/folders sharing the date/time).

Upvotes: 0

Related Questions