Меню Рубрики

Mysql python windows pip

Как установить модуль Python MySQLdb с помощью pip?

Как я могу установить MySQLdb модуль для Python с использованием pip?

16 ответов

это легко сделать, но трудно запомнить правильное написание:

Если вам нужно 1.2.X версии (только устаревший Python), используйте pip install MySQL-python

Примечание: некоторые зависимости, возможно, должны быть на месте при выполнении вышеуказанной команды. Некоторые советы о том, как установить их на различных платформах:

Ubuntu 14, Ubuntu 16, Debian 8.6 (jessie)

Fedora 24:

Mac OS

если это не удается, попробуй!—7—>

начиная с новой системы Ubuntu 14.04.2, эти две команды были необходимы:

просто выполнение «pip install» само по себе не сработало.

у меня были проблемы с установкой 64-битной версии MySQLdb на Windows через Pip (источники компиляции проблем) [32-битная версия установлена ok]. Удалось установить скомпилированный MySQLdb из .файл whl доступен изhttp://www.lfd.uci.edu /

например, если вы экономите в C:/ вы можно установить через

pip install c:/MySQL_python-1.2.5-cp27-none-win_amd64.whl

Последующие действия: если у вас установлена 64-битная версия Python, то вы хотите установить 64-битную версию AMD MySQLdb по ссылке выше [т. е. даже если у вас есть процессор Intel]. Если вы вместо этого попытаетесь установить 32-разрядную версию, я думаю, вы получите неподдерживаемую ошибку колеса в комментариях ниже.

хорошо это сработало для меня:

затем поместите код ниже в init.py (имя_проекта/init.py)

моя среда (python3.5, django1.10) и это работает для меня!

Я пробовал все варианты, но не смог заставить его работать на платформе Redhat. Я сделал следующее, чтобы заставить его работать: —

после установки пакета удалось импортировать модуль следующим образом в интерпретаторе: —

перейти к pycharm потом идут по умолчанию настройки — > Пип (двойной клик) — pymsqldb..— > установить-после установки использовать в программе, как это

вы можете пойти на это сайт скачать пакет.

у меня тоже такая же проблема.Выполните следующие действия, если вы находитесь на Windows. Идти к: 1.Мой Компьютер 2.системное свойство 3.Предварительные Настройки Системы 4. На вкладке «Дополнительно» нажмите кнопку с надписью «Переменные среды» 5. Затем в разделе системные переменные вы должны добавить / изменить следующие переменные: PYTHONPATH и Path. Вот вставка того, как выглядят мои переменные: путь python:

посмотреть этот ссылке для ссылка

Если вы используете Raspberry Pi [Raspbian OS]

сначала необходимо установить команду pip

Так что просто установите последовательно

Если вы не можете установить mysqlclient вы также можете установить pymysql:

pip install pymysql

это работает так же, как MySqldb. После этого используйте pymysql вместо MySQLdb

приведенный выше ответ велик, но могут возникнуть некоторые проблемы, когда мы используем pip для установки MySQL-python в Windows

например, ему нужны некоторые файлы, связанные с Визуальный Stdio .Одним из решений является установка VS2008 или 2010. Очевидно, это стоило слишком дорого.

другой способ-это ответ @bob90937 . Я здесь, чтобы кое-что добавить.

gohlke / pythonlibs, У может загрузите много двоичных файлов Windows многих научных пакетов расширения с открытым исходным кодом для официального распространения CPython языка программирования Python.

вернемся к теме,мы можем выбрать MySQL-python (py2) или Mysqlclient(py3) и использовать pip install установить. это дает нам большое удобство!

pip install mysql-connector-python как отмечается в документации:

Источник

Installing mysqlclient in Python 3.6 in windows

I want to install MySqlclient on my windows system. I am Currently using Python 3.6. After going through the various post over Stackoverflow, I could Not find the correct way. This is what I have done so far:

1) Installation by using pip pip install mysqlclient . Error:

I already have Microsoft Visual C++ installed on my laptop. Some are saying you need 2015 edition.

2) Installation by using wheel file pip install mysqlclient-1.3.13-cp36-cp36m-win_amd64.whl . Error:

Requirement mysqlclient-1.3.13-cp36-cp36m-win_amd64.whl looks like a filename, but the file does not exist. mysqlclient-1.3.13-cp36-cp36m-win_amd64.whl is not a supported wheel on this platform.

2.1) Changing the whl file to different version pip install mysqlclient-1.3.13-cp36-cp36m-win32.whl . Error:

Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: ‘C:\\Users\\Foxtrot\\Desktop\\finaltest\\mysqlclient-1.3.13-cp36-cp36m-win32.whl’

Other things that are done: updated setuptools, updated wheel.

9 Answers 9

I can’t find mysqlclient-1.3.13’s whl file on PyPi. So you need to compile it from source. Unfortunately it’s not easy. I’m not Windows guy, so I only can recommend guide like this

Had the same problem, searched the web etc. Here this answer:

It has all the instructions. In short go to this site: https://www.lfd.uci.edu/

There you will find mysqlclient‑1.3.13‑cp36‑cp36m‑win32.whl mysqlclient‑1.3.13‑cp36‑cp36m‑win_amd64.whl

Download the correct file for your platform.

Then use your downloaded wheels file with pip and your done:

pip install c:\mysqlclient‑1.3.13‑cp36‑cp36m‑win_amd64.whl

gohlke/pythonlibs has lots of lots of compiled libaries to solve the problem of building them from source yourself. They even compile them for python 3.7 🙂

Alternative Solution

You can also download Visual C++ Build Tools and then you should be able to install every (at least to my knowledge) version of mysqlclient with pip. To do this go to this site: https://www.scivision.co/python-windows-visual-c++-14-required/ there you can find out which version of Build Tools you need and you can also find a link to download the installer. Be aware though Build Tools require more than 4GB of free disk space.

I am using python3.7 on Windows 10 operating system. I had same issue and after a long research I had installed it successfully.

Install «Microsoft Visual C++ Build Tools» AND My OS is having 64 bit operating system but still then it need to install 32 bit version «mysqlclient‑1.4.2‑cp37‑cp37m‑win32.whl»

pip install [path_to_downloaded_file] eg: C:\Users\Ds\mysqlclient-1.4.2-cp37-cp37m-win32.whl

use pipenv instead of pip if you are using virtual environment.

The error means that the package has not yet been compiled for your versions of OS and Python. So pip tries to build it from the source for you.

There are two possible solutions.

The first option is to install the most recent version of Microsoft Visual C++ Build Tools. Just go ahead and download it from the Microsoft website. Then pip should be able to compile the package.

Another option is using an unofficial binary. As mentioned here, a resource proved to be useful is https://www.lfd.uci.edu/

gohlke/pythonlibs/#mysql-python . Just download the pre-compiled package and install it using

pip install c:\path-to-a-pre-compiled-package

Tell pip not to use sources and use binary packages instead:

Had the same problem just day. Tried to install mysqlclient on a Windows Server R2.

«MySQL Connector C 6.1» was installed in the wrong directory: «C:\Program Files\MySQL» instead of «C:\Program Files (x86)\MySQL» where it should be for me.
—> Copied «MySQL Connector C 6.1» to «C:\Program Files (x86)\MySQL» Directory.

«C:\Users\MoBoo\AppData\Local\Temp» was Read-Only: Therefore pip couldn’t compile files into Temp dir.
—> Allow Write access to «C:\Users\MoBoo\AppData\Local\Temp» Directory.

Here is what worked for me. I uninstalled mysql and re-installed it.

Then simply re-install, so it picked the current version «1.4.2.post1»

Which interestingly, works straightaway.

for this error, most of user’s suggest to install vs build but there is an alternative which works perfectly in my case and is sure for you too. Download latest MySQL client from here mysqlclients

Here you can see many version but prefer to download the latest one which has 32 bit and 64-bit files. download theme and past the file on your projects root folder then run the same command but with the full file name of downloaded mysqlclient.

in my case, the file is this also if have already the XAMPP server then you can use its PHPMyAdmin with python. You just need to change on your roots setting.py file for this. Something like this

The port is the same which you see on xampp panel just before the start button of MySQL. After changing this you just again start your server by hitting this command

If you didn’t see any error then congratulations you successfully connected with MySQL database.

Источник

How to install Python MySQLdb module using pip?

How can I install the MySQLdb module for Python using pip?

20 Answers 20

It’s easy to do, but hard to remember the correct spelling:

If you need 1.2.x versions (legacy Python only), use pip install MySQL-python

Note: Some dependencies might have to be in place when running the above command. Some hints on how to install these on various platforms:

Ubuntu 14, Ubuntu 16, Debian 8.6 (jessie)

Fedora 24:

Mac OS

Starting from a fresh Ubuntu 14.04.2 system, these two commands were needed:

Just doing the «pip install» by itself did not work.

Then put the code below into __init__.py ( projectname/__init__.py )

My environment is (python3.5, django1.10) and this solution works for me!

I had problems installing the 64-bit version of MySQLdb on Windows via Pip (problem compiling sources) [32bit version installed ok]. Managed to install the compiled MySQLdb from the .whl file available from http://www.lfd.uci.edu/

For example if you save in C:/ the you can install via

pip install c:/MySQL_python-1.2.5-cp27-none-win_amd64.whl

Follow-up: if you have a 64bit version of Python installed, then you want to install the 64-bit AMD version of MySQLdb from the link above [i.e. even if you have a Intel processor]. If you instead try and install the 32-bit version, I think you get the unsupported wheel error in comments below.

gohlke/pythonlibs/#mysql-python to download whl file (I dl’d 64 bit to match my 64 bit Python install). Saved file into c:/ directory and ran pip install c:/MySQL_python-1.2.5-cp27-none-win_amd64.whl It installed in seconds and was good to go. Too easy! – curtisp Oct 11 ’16 at 18:43

well this worked for me:

this is for python 3.x

I tried all the option but was not able to get it working on Redhat platform. I did the following to make it work:-

Once the package was installed was able to import module as follows in the interpreter:-

Go to pycharm then go to default setting —> pip (double click) — pymsqldb..— > install —after installing use in a program like this

If you are unable to install mysqlclient you can also install pymysql:

pip install pymysql

This works same as MySqldb. After that use pymysql all over instead of MySQLdb

If you are use Raspberry Pi [Raspbian OS]

There are need to be install pip command at first

So that just install Sequently

You can go to this website to download the package.

I had the same problem too.Follow these steps if you are on Windows. Go to: 1.My Computer 2.System Properties 3.Advance System Settings 4. Under the «Advanced» tab click the button that says «Environment Variables» 5. Then under System Variables you have to add / change the following variables: PYTHONPATH and Path. Here is a paste of what my variables look like: python path:

See this link for reference

Many of the given answers here are quite confusing so I will try to put it simply. It helped me to install this

and then use the following command in the python file

This way you can use MySQLdb without any problems.

The above answer is great, but there may be some problems when we using pip to install MySQL-python in Windows

for example,It needs some files that are associated with Visual Stdio .One solution is installing VS2008 or 2010……Obviously,it cost too much.

Another way is the answer of @bob90937 . I am here to do something to add.

gohlke/pythonlibs, u can download many Windows binaries of many scientific open-source extension packages for the official CPython distribution of the Python programming language.

Back to topic,we can choose the MySQL-python(py2) or Mysqlclient(py3) and use pip install to install. it gives us Great convenience!

Источник

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *

  • Mysql myphpadmin на сервере windows 2008
  • Mysql gui для windows
  • Mysql for windows installer
  • Mysql command line windows
  • Mysql client windows client