RaspberryPi - MySQLdb - python

Hello Stackoverflow users,
For my student project i need to use python and mysql, but when i try to use i've this kind of error
Traceback (most recent call last):
File "myRFIDserv.py", line 2, in
import MySQLdb
ImportError: No module named MySQLdb
I 've try to fix this with the installation of python-mysqldb but they have also a error ...
Package python-mysqldb is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'python-mysqldb' has no installation candidate
MySQL-server are already install !
I've try sudo pip install MySQL-python but i have this kind of error
Collecting MySQL-python
Using cached MySQL-python-1.2.5.zip
Complete output from command python setup.py egg_info:
sh: 1: mysql_config: not found
Traceback (most recent call last):
File "<string>", line 20, in <module>
File "/tmp/pip-build-lbb0Fd/MySQL-python/setup.py", line 17, in <module>
metadata, options = get_config()
File "setup_posix.py", line 43, in get_config
libs = mysql_config("libs_r")
File "setup_posix.py", line 25, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-lbb0Fd/MySQL-python
I don't understand, someone can help me ? ;)

maybe you can try
pip install MySQL-python

Related

python setup.py egg_info error mysqlclient

I just started learning Python using Django and I just seemed to be stuck at the same place for 3 days, every time I try to run the following command in my terminal using Pycharm (Yep, I am using a Mac) I get the below error:
Command: pip install mysqlclient
Error:
Collecting mysqlclient
Using cached mysqlclient-1.3.12.tar.gz
Complete output from command python setup.py egg_info:
/bin/sh: mysql_config: command not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/3z/_xzmzzh90z9dj90cb70p3q0c0000gn/T/pip-build-c7mudszc/mysqlclient/setup.py", line 17, in <module>
metadata, options = get_config()
File "/private/var/folders/3z/_xzmzzh90z9dj90cb70p3q0c0000gn/T/pip-build-c7mudszc/mysqlclient/setup_posix.py", line 44, in get_config
(venv) Mervins-MacBook-Pro:untitled mervinkobola$ pip install mysqlclient
Collecting mysqlclient
Using cached mysqlclient-1.3.12.tar.gz
Complete output from command python setup.py egg_info:
/bin/sh: mysql_config: command not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/3z/_xzmzzh90z9dj90cb70p3q0c0000gn/T/pip-build-w_jamo3b/mysqlclient/setup.py", line 17, in <module>
metadata, options = get_config()
File "/private/var/folders/3z/_xzmzzh90z9dj90cb70p3q0c0000gn/T/pip-build-w_jamo3b/mysqlclient/setup_posix.py", line 44, in get_config
(venv) Mervins-MacBook-Pro:untitled mervinkobola$ pip install mysqlclient
Collecting mysqlclient
Using cached mysqlclient-1.3.12.tar.gz
Complete output from command python setup.py egg_info:
/bin/sh: mysql_config: command not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/3z/_xzmzzh90z9dj90cb70p3q0c0000gn/T/pip-build-xefx4qk7/mysqlclient/setup.py", line 17, in <module>
metadata, options = get_config()
File "/private/var/folders/3z/_xzmzzh90z9dj90cb70p3q0c0000gn/T/pip-build-xefx4qk7/mysqlclient/setup_posix.py", line 44, in get_config
libs = mysql_config("libs_r")
File "/private/var/folders/3z/_xzmzzh90z9dj90cb70p3q0c0000gn/T/pip-build-xefx4qk7/mysqlclient/setup_posix.py", line 26, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
OSError: mysql_config not found
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/3z/_xzmzzh90z9dj90cb70p3q0c0000gn/T/pip-build-xefx4qk7/mysqlclient/
Please help me understand whats going on and how I can solve it. Above all I can't seem to run the following :
python manage.py migrate (as I haven't installed mysqlclient)
Thank you in advance for your assistance.
Sometimes the variable mysql_config is set in the Terminal but not in PyCharm so this is why you're getting this error.
The solution is:
run the PyCharm from the terminal with this command:
/Applications/PyCharm\ CE.app/Contents/MacOS/pycharm
After that (in PyCharm) install the packages you need (probably they are in your requirements.txt, for example the mysqlclient),
Close the program and re-open
Now it should have all the packages installed properly

i can't install mysqlclient and pillow in python

i want to install mysqlclient but it returns me
(venv)amir#amg76:~/Documents/Computer/Python/Django/vira/virasciencecom$ pip3 install mysqlclient==1.3.7
Collecting mysqlclient==1.3.7
Using cached mysqlclient-1.3.7.tar.gz
Complete output from command python setup.py egg_info:
/bin/sh: 1: mysql_config: not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-c5i8m5ok/mysqlclient/setup.py", line 17, in <module>
metadata, options = get_config()
File "/tmp/pip-build-c5i8m5ok/mysqlclient/setup_posix.py", line 44, in get_config
libs = mysql_config("libs_r")
File "/tmp/pip-build-c5i8m5ok/mysqlclient/setup_posix.py", line 26, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
OSError: mysql_config not found
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-c5i8m5ok/mysqlclient/
the same thing happen when i try to install pillow and i use python 3.6 and ubuntu 17.10
can any body help me?
You need to install libmysqlclient-dev or libmariaclient-dev from your distro package repository, depending whether you're using mysql or mariadb respectively.

How to Install python 2.7 mysql on Digital Ocean

I tried install mysql using this command in my droplet on Digital Ocean:
pip install MySQL-python
But it not working and show this message:
Collecting MySQL-python
Using cached MySQL-python-1.2.5.zip
Complete output from command python setup.py egg_info:
sh: 1: mysql_config: not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-kjiS0F/MySQL-python/setup.py", line 17, in <module>
metadata, options = get_config()
File "setup_posix.py", line 43, in get_config
libs = mysql_config("libs_r")
File "setup_posix.py", line 25, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-kjiS0F/MySQL-python/
might be issue with the locale settings.
try this:
$ export LC_ALL=C

Unable to install mysqlclient using pip3 on MacOS sierra

I want to use mysql in django so, trying to download mysqlclent using $ pip3 install mysqlclient but always this error comes up
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/hb/vmtpfjk12fdcm_8l95hfqzmr0000gn/T/pip-build-pm_wn_w8/mysqlclient/
here are my terminal logs
$ pip3 install mysqlclient
Collecting mysqlclient
Using cached mysqlclient-1.3.9.tar.gz
Complete output from command python setup.py egg_info:
/bin/sh: mysql_config: command not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/hb/vmtpfjk12fdcm_8l95hfqzmr0000gn/T/pip-build-pm_wn_w8/mysqlclient/setup.py", line 17, in <module>
metadata, options = get_config()
File "/private/var/folders/hb/vmtpfjk12fdcm_8l95hfqzmr0000gn/T/pip-build-pm_wn_w8/mysqlclient/setup_posix.py", line 44, in get_config
libs = mysql_config("libs_r")
File "/private/var/folders/hb/vmtpfjk12fdcm_8l95hfqzmr0000gn/T/pip-build-pm_wn_w8/mysqlclient/setup_posix.py", line 26, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
OSError: mysql_config not found
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/hb/vmtpfjk12fdcm_8l95hfqzmr0000gn/T/pip-build-pm_wn_w8/mysqlclient/
Please help
$ pip3 install mysqlclient
indicates that you are intending to use Python3 install the package. Based on the errors in the description, I believe that MySQL maybe missing from your machine. According to mysqlclient repo, MySQLConnectorC is one of the prerequisite to run mysqlclient on OSX.
brew install mysql-connector-c
should solve your issue.
Try adding MySQL to your PATH :
export PATH=${PATH}:/usr/local/mysql/bin/

What package should I use to query Mysql Databases in Python?

I need to query a Mysql database with Python.
I have virtual env installed and also PIP, I have tried to install this package, http://pypi.python.org/pypi/MySQL-python/#downloads but without success.
I have parformed the command:
sudo pip install http://pypi.python.org/packages/source/M/MySQL-python/MySQL-python-1.2.3.tar.gz#md5=215eddb6d853f6f4be5b4afc4154292f
And I have got the error:
(python_virtualenv)andre#ubuntu:~/workspace/RS_r/src$ sudo pip install http://pypi.python.org/packages/source/M/MySQL-python/MySQL-python-1.2.3.tar.gz#md5=215eddb6d853f6f4be5b4afc4154292f
[sudo] password for andre:
Downloading/unpacking http://pypi.python.org/packages/source/M/MySQL-python/MySQL-python-1.2.3.tar.gz#md5=215eddb6d853f6f4be5b4afc4154292f
Downloading MySQL-python-1.2.3.tar.gz (70Kb): 70Kb downloaded
Running setup.py egg_info for package from http://pypi.python.org/packages/source/M/MySQL-python/MySQL-python-1.2.3.tar.gz#md5=215eddb6d853f6f4be5b4afc4154292f
sh: mysql_config: not found
Traceback (most recent call last):
File "<string>", line 14, in <module>
File "/tmp/pip-l0kPkg-build/setup.py", line 15, in <module>
metadata, options = get_config()
File "setup_posix.py", line 43, in get_config
libs = mysql_config("libs_r")
File "setup_posix.py", line 24, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found
Complete output from command python setup.py egg_info:
sh: mysql_config: not found
Traceback (most recent call last):
File "<string>", line 14, in <module>
File "/tmp/pip-l0kPkg-build/setup.py", line 15, in <module>
metadata, options = get_config()
File "setup_posix.py", line 43, in get_config
libs = mysql_config("libs_r")
File "setup_posix.py", line 24, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found
----------------------------------------
Command python setup.py egg_info failed with error code 1
Storing complete log in /home/andre/.pip/pip.log
My questions. What package should I install to query Mysql databases and how should I install? Pip install should be used in this case?
Give me a clue.
Best regards,
The error message is self-speaking
sh: mysql_config: not found
mysql_config is part of the MySQL installation is either not installed nor not available
from the $PATH. This is the problem to be solved - not the question about binding alternatives.
The error message shows you are missing mysql_config (and seem to be on an Ubuntu machine):
EnvironmentError: mysql_config not found
...
sh: mysql_config: not found
dpkg -S can show which package provides mysql_config -- assuming you have a machine with mysql_config installed... :)
% dpkg -S $(which mysql_config)
libmysqlclient-dev: /usr/bin/mysql_config
Therefore, it looks like you need to install the libmysqlclient-dev package.
PS. If you don't have a machine with mysql_config installed, the same info can be found at http://packages.ubuntu.com/.
Have a look at this links: one, two, three
The source you can find here

Categories

Resources