First, start Pycharm, create a Django project in a virtual environment
1. Menu-file-new Project ...
2. Select "Django" in the "Select Project Type" window
3, click "Interpreter" the rightmost setting icon, select "Create virtualenv"
Parameters:
Location:e:\pycharmprojects\tm
Interpreter:e:\virtualenv\tm
Application Name:tmjob
Enable Django admin: Tick
4. Set "name" (Virtual Environment Name) "Location" (Virtual Environment Storage) "Base interpreter" (based on which Python interpreter) in the "Create Virtual Environment" window Inherit Global Site-packages "(Inherited Site-packages Package)
Parameters:
Name:tm
Location:e:\virtualenv\tm
Base interpreter:windows installed python2.7.10 (32bit)
Inherit Global site-packages: Uncheck
Description
If base interpreter is based on the 2.x version, the virtual Environment version is also 2.x. If based on the 3.x version, the virtual Environment version is also 3.x.
"Inherit Global Site-packages" Inherits "Site-packages" from "Base interpreter"
5, "Create Virtual environment" set up and click "OK", in the Virtual environment directory "E:\VIRTUALENV\TM" under the virtual environment file generation
6. After the "Select Project Type" is set up, click "Create" to build the project file under the project directory "E:\PycharmProjects\TM".
7. Pycharm Project
Second, add MySQL extension
Menu-file-settings
1. Under "Project:tm"-"Project Interpreter", click the "+" in the expansion pack list or double-click the blank part of the list with the left mouse button.
Search for "MySQLdb", no matching. Search for "Mysql-python" again and click "Install package" for installation
However, hehe ...
All right, I'm little white. Command installation, Pip install MySQLdb
2, start the cmd, start the virtual environment, the command is as follows:
Okay, pip install MYSQLDB command won't work.
Bonus a PIP Upgrade command: python-m pip install--upgrade pip
Try Easy_install after Pip doesn't work.
Easy_instal MySQLdb is not feasible, easy_instal Mysql-python can be used. Or go to the official website to download, and then install the source code in the virtual environment
Again go to Pycharm project settings under View, found that the installation is successful!!!
Pycharm Virtual Environment VIRTUALNV installing MySQL Extensions