简体   繁体   中英

Cannot install mysqlclient with PIP in Visual Studio Virtual Env Python 3.5 64bit

I am trying to install mysqlclient using PIP inside of visual studio 2015 update 3, running a virtual env with python 3.5 64bit. It is for a django web app.

I get the following message when I try to install it.

Installing 'mysqlclient'
E:\Users\Tim Baker\Documents\Visual Studio 2015\Projects\DjangoWebProject1\DjangoWebProject1\env\Scripts\python.exe: No module named pip.__main__; 'pip' is a package and cannot be directly executed
'mysqlclient' failed to install. Exit code: 1

First, make sure python is listed in your path, I have noticed this can be a problem.

Next check to make sure you are not exceeding the windows path length limit, you may need to move your virtual env to a folder with less characters.

Third, make sure you have the latest version of PIP by running

python -m pip install -U pip setuptools

Make sure you have C++ installed, and the correct version, this can cause issues.

Eventually what worked for me when I had this problem was installing a previous version:

pip install mysqlclient==1.3.4

Prior to finding that this worked, I found that I could also use the oracle mysql connector...

Also, you can download the binaries directly from: http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysqlclient

Choose the correct version of python, and version of windows that you have and extract it into your project folder. For you if you're running python 3.5x64 you want this one: mysqlclient-1.3.9-cp35-cp35m-win_amd64.whl

I think you need to install pip first. Your "Visual Studio" Python Version might not be the same as your default Python version on you pc and therefore pip is not automaticly available.

Download get-pip.py and call it with your python version:

python get-pip.py

After that, try it again!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM