python virtual environment under virtualenv install MySQL-python (1.2.3)

The article is useful suggestions favorites

When we develop python application under Windows, you may need to install a variety of third-party modules, but if you do not want to pollute public python environment, how to do it? Virtualenv best to create a virtual environment in their respective python project. Bloggers recently needed to install MySQL-python module in a virtual environment, this module if by way of pip command line installation, it is likely to encounter a variety of egg pain prompted some missing Microsoft DLLs problems, this module the installation, in addition to the command line, but another way is to download the exe file to install, but in a virtual environment so they can not be installed. So, I thought, adopted exe installed, then in the end the Lib \ site-packages python installation directory which files created under the directory it? I copy these files to the appropriate directory virtual environment, can achieve the purpose of mysql installed in a virtual environment? A try really can. Now the process from creation to installation mysqldb of virtualenv briefly.
First, create a virtual machine environment in the project directory
in windows command line into the project root directory, and then execute the following command:

D:\pythonWorkspace\testENV>virtualenv venv
New python executable in venv\Scripts\python.exe
Installing setuptools, pip, wheel...done.

D: \ pythonWorkspace \ testENV>
then the virtual environment is now installed, we can see the emergence of a project directory under a venv folder (venv is the name of our virtual environment, you can easily play).
Note that, by default, the virtual environment will depend on site packages system environment, that system has been installed third-party package will be installed in the virtual environment, if you do not want to rely on these package, you can add parameters --no -site-packages to create a virtual environment:

D: \ pythonWorkspace \ testENV> virtualenv --no-site-packages [ virtual environment directory]
Postscript: The virtual environment is created, the only open, in order to install the package to the virtual environment. So how do you start a virtual environment? windows environment, you can cmd command line runs directly /Scripts/activate.bat program under virtual environment directory, source Linux environment can use the command in a virtual environment directory, for example: #source ./bin/activate to start.

Second, in a virtual environment to install MySQL-python
after the virtual environment is created, we have used a good exe install mysql involved in a public environment four files copied to the corresponding directory virtual environment (copy files to the site-packages folder under the virtual environment next to):

-1.2.3-py2.7.egg-MySQL_python info
MySQLdb
_mysql.pyd
_mysql_exceptions.py
then we have not installed under examination:

import MySQLdb
found to be incorrect report, on behalf installed.

exe files download version MySQLdb module (MySQL-python-1.2.3.win-amd64-py2.7.exe)

 

Guess you like

Origin www.cnblogs.com/zmdComeOn/p/11183860.html