Installing flask-mysqldb gives "mysql_config not found" - python

I'm trying to install flask-mysql on ubuntu 18.04 and I keep getting this error:
(base) ether#ether:~/Documents/loginsystem$ pip install flask-mysqldb
Collecting flask-mysqldb
Using cached https://files.pythonhosted.org/packages/62/e3/955c845efe1aacf30c8e2607470544ede36aa1044f6382c809f13e014104/Flask-MySQLdb-0.2.0.tar.gz
Requirement already satisfied: Flask>=0.10 in /home/ether/anaconda3/lib/python3.7/site-packages (from flask-mysqldb) (1.0.2)
Collecting mysqlclient (from flask-mysqldb)
Using cached https://files.pythonhosted.org/packages/d0/97/7326248ac8d5049968bf4ec708a5d3d4806e412a42e74160d7f266a3e03a/mysqlclient-1.4.6.tar.gz
Complete output from command python setup.py egg_info:
/bin/sh: 1: mysql_config: not found
/bin/sh: 1: mariadb_config: not found
/bin/sh: 1: mysql_config: not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-txlk8w2u/mysqlclient/setup.py", line 16, in <module>
metadata, options = get_config()
File "/tmp/pip-install-txlk8w2u/mysqlclient/setup_posix.py", line 61, in get_config
libs = mysql_config("libs")
File "/tmp/pip-install-txlk8w2u/mysqlclient/setup_posix.py", line 29, 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-install-txlk8w2u/mysqlclient/
I tried to run sudo pip install and pip3 install flask-mysqldb but each time I received the same error as posted above.
What can I do to fix this?

The error message is pretty clear:
OSError: mysql_config not found
You need mysql_config. Install either libmariadbclient-dev or libmysqlclient-dev with apt.
Then try using pip again, but not with sudo.
Mixing system-level Python packages and pip-installed packages is a recipe for disaster. It looks like you already have a virtualenv for your project, so use that. Bonus points if you specify your dependencies in a requirements.txt file or Pipfile.

Related

MySQL pip3 install error: metadata-generation-failed

Ive tried updating pip and installing different packages but nothing seems to work. im not sure if i have to run a command in konsole or alacritty but any help would be appreciated. i use fedora btw
sh-5.1$ pip3 install mysql
Defaulting to user installation because normal site-packages is not writeable
Collecting mysql
Using cached mysql-0.0.3-py3-none-any.whl (1.2 kB)
Collecting mysqlclient
Using cached mysqlclient-2.1.1.tar.gz (88 kB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [16 lines of output]
/bin/sh: line 1: mysql_config: command not found
/bin/sh: line 1: mariadb_config: command not found
/bin/sh: line 1: mysql_config: command not found
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "/tmp/pip-install-lol73zmo/mysqlclient_d4096e3cc1ee4a6fbc53886cb9de5a17 /
setup.py", line 15, in <module>
metadata, options = get_config()
File "/tmp/pip-install-lol73zmo/mysqlclient_d4096e3cc1ee4a6fbc53886cb9de5a17
/setup_posix.py", line 70, in get_config
libs = mysql_config("libs")
File "/tmp/pip-install-lol73zmo/mysqlclient_d4096e3cc1ee4a6fbc53886cb9de5a17
/setup_posix.py", line 31, in mysql_config
raise OSError("{} not found".format(_mysql_config_path))
OSError: mysql_config not found
mysql_config --version
mariadb_config --version
mysql_config --libs
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
before installing you have to resolve dependencies .
sudo apt-get install python3-dev libmysqlclient-dev
then inside a virtual environment:
pip3 install mysqlclient
then
pip3 install mysql
it should work

Why can't i install the requirements.txt content?

(env) user#name:~/$ pip install -r requirements.txt
Collecting Shapely==1.5.13 (from -r requirements.txt (line 1))
Using cached Shapely-1.5.13.tar.gz
Complete output from command python setup.py egg_info:
Failed `CDLL(libgeos_c.so.1)`
Failed `CDLL(libgeos_c.so)`
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-p0Fy8v/Shapely/setup.py", line 38, in <module>
from shapely._buildcfg import geos_version_string, geos_version, \
File "/tmp/pip-build-p0Fy8v/Shapely/shapely/_buildcfg.py", line 167, in <module>
fallbacks=['libgeos_c.so.1', 'libgeos_c.so'])
File "/tmp/pip-build-p0Fy8v/Shapely/shapely/_buildcfg.py", line 161, in load_dll
libname, fallbacks or []))
OSError: Could not find library geos_c or load any of its variants ['libgeos_c.so.1', 'libgeos_c.so']
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-p0Fy8v/Shapely/
requirements.txt content :
Shapely==1.5.13
Flask==0.10.1
matplotlib==1.5.1
scipy==0.19.0
plumbum==1.6.2
numpy==1.12.1
ipython==5.5
Pillow==4.2.1
opencv-python==3.2.0.6
trying to run pip install -r requirements.txt but i keep on getting that error described above, i just installed python and pip and basically everything else after my format on linux 16.04 so not sure what's going wrong.
Edit:
I removed Shapely==1.5.13 from the requirements.txt to test if it;s the issue and i got that error again Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-oVKNjq/matplotlib/

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.

installing mysqldb for flask ERROR [OSX]

macOS 10.13.2
Python 2.7.14
Hi all! I'm currently working on a website made in python (flask), but I'm experiencing an issue when I try to install MYSQLDB for python. I want to use it for my database where I can store users and other data. First of all, here is the terminal output when I input:
pip install flask-mysqldb
Collecting flask-mysqldb
Using cached Flask-MySQLdb-0.2.0.tar.gz
Requirement already satisfied: Flask>=0.10 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from flask-mysqldb)
Collecting mysqlclient (from flask-mysqldb)
Using cached mysqlclient-1.3.12.tar.gz
Complete output from command python setup.py egg_info:
sh: mysql_config: command not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/b3/4tr2p1w10cx70rqpqh28m30r0000gn/T/pip-build-4sX19x/mysqlclient/setup.py", line 17, in <module>
metadata, options = get_config()
File "setup_posix.py", line 44, in get_config
libs = mysql_config("libs_r")
File "setup_posix.py", line 26, 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 /private/var/folders/b3/4tr2p1w10cx70rqpqh28m30r0000gn/T/pip-build-4sX19x/mysqlclient/
This error message doesn't help me at all, I don't know what to do with it. After getting the error I searched for a solution on different sites, but none of the solutions is working for me. Here are some 'solutions' I tried
sudo pip3 install git+https://github.com/donnemartin/gitsome.git
sudo -H pip3 install gitsome
sudo pip install --upgrade setuptools
When I input:
sudo -H pip install flask-mysqldb
This is the output:
Collecting flask-mysqldb
Downloading Flask-MySQLdb-0.2.0.tar.gz
Requirement already satisfied: Flask>=0.10 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from flask-mysqldb)
Collecting mysqlclient (from flask-mysqldb)
Downloading mysqlclient-1.3.12.tar.gz (89kB)
100% |████████████████████████████████| 92kB 556kB/s
Complete output from command python setup.py egg_info:
sh: mysql_config: command not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/tmp/pip-build-P4Y1ub/mysqlclient/setup.py", line 17, in <module>
metadata, options = get_config()
File "setup_posix.py", line 44, in get_config
libs = mysql_config("libs_r")
File "setup_posix.py", line 26, 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 /private/tmp/pip-build-P4Y1ub/mysqlclient/
I would really appreciate any help to resolve this problem! Thanks in advance.
If your concern is to manipulate the DB, I will recommend using Flask-SQLAlchemy and right here you will find how to connect using MySQL databases.
Flask-SQLAlchemy is a ORM (Object Relational Mapper) so, you will probably have to code map the DB
I hope this helps!

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/

Categories

Resources