pip install MySQL-python==1.2.5 not working [duplicate] - python

This question already has answers here:
pip install mysql-python fails with EnvironmentError: mysql_config not found
(24 answers)
Closed 2 years ago.
I'm trying to install MySQL-python with pip.
I'm using Python v2.7.18 and pip v20.3.4
I'm trying it with:
pip install MySQL-python==1.2.5
But it gives this error:
Defaulting to user installation because normal site-packages is not writeable
Collecting MySQL-python==1.2.5
Using cached MySQL-python-1.2.5.zip (108 kB)
ERROR: Command errored out with exit status 1:
command: /usr/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-zuV7aL/mysql-python/setup.py'"'"'; __file__='"'"'/tmp/pip-install-zuV7aL/mysql-python/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-TefBrj
cwd: /tmp/pip-install-zuV7aL/mysql-python/
Complete output (10 lines):
sh: 1: mysql_config: not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-zuV7aL/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
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
What am I doing wrong?

You need to install dev libs for mysql client:
sudo apt-get install libmysqlclient-dev

Related

Module Not Getting Installed: pip3 install morphy

I want to install the python module morphy on Ubuntu 20.04.2, but I am getting an error.
I tried this:
pip3 install morphy
I got this output:
Collecting morphy
Using cached morphy-0.2.tar.gz (9.3 kB)
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-uygwfbh3/morphy/setup.py'"'"'; __file__='"'"'/tmp/pip-install-uygwfbh3/morphy/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-uygwfbh3/morphy/pip-egg-info
cwd: /tmp/pip-install-uygwfbh3/morphy/
Complete output (5 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-uygwfbh3/morphy/setup.py", line 3, in <module>
with open('README.md', 'r') as fp:
FileNotFoundError: [Errno 2] No such file or directory: 'README.md'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
It worked on Windows 10 though. My pip3 version is:
pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)
I tried this too:
pip install morphy
I got this output:
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Defaulting to user installation because normal site-packages is not writeable
Collecting morphy
Using cached morphy-0.2.tar.gz (9.3 kB)
ERROR: Command errored out with exit status 1:
command: /usr/bin/python2 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ICmImS/morphy/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ICmImS/morphy/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-lPhE0U
cwd: /tmp/pip-install-ICmImS/morphy/
Complete output (5 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-ICmImS/morphy/setup.py", line 3, in <module>
with open('README.md', 'r') as fp:
IOError: [Errno 2] No such file or directory: 'README.md'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
It is clear from the output that the README.md file is missing from the package. What should I do?
Looks like the Linux version of the package might be broken and it doesn't seem to be maintained anymore.
You can use the following workaround:
try installing again but tell pip not to clean up the temporary files: pip install morphy --no-clean
enter the temporary directory with the package contents - find its name in the output from the pip install command
create the files setup.py needs
execute python setup.py install manually
if you know what this package's requirements are, install them manually
$ pip install morphy --no-clean
Collecting morphy
Using cached morphy-0.2.tar.gz (9.3 kB)
ERROR: Command errored out with exit status 1:
command: /home/user/env/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-vluz3ja_/morphy/setup.py'"'"'; __file__='"'"'/tmp/pip-install-vluz3ja_/morphy/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-vluz3ja_/morphy/pip-egg-info
cwd: /tmp/pip-install-vluz3ja_/morphy/
Complete output (5 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-vluz3ja_/morphy/setup.py", line 3, in <module>
with open('README.md', 'r') as fp:
FileNotFoundError: [Errno 2] No such file or directory: 'README.md'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
$ cd /tmp/pip-install-vluz3ja_/morphy
$ touch README.md
$ touch requirements.txt
$ python setup.py install
...
Installed /home/user/env/lib/python3.8/site-packages/morphy-0.2-py3.8.egg
Processing dependencies for morphy==0.2
Finished processing dependencies for morphy==0.2

How to Correctly install MySQL module in Python

I am new to coding and ubuntu, and I am trying to insert some data to MySQL using Python, but I am having some error in installing the mysql module.
I am having this error:
**pip install mysql**
Defaulting to user installation because normal site-packages is not writeable
Collecting mysql
Using cached mysql-0.0.2.tar.gz (1.9 kB)
Collecting mysqlclient
Using cached mysqlclient-2.0.2.tar.gz (88 kB)
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-8pt10wd4/mysqlclient_5e8d8ff6d905420ea115c27e23267248/setup.py'"'"'; __file__='"'"'/tmp/pip-install-8pt10wd4/mysqlclient_5e8d8ff6d905420ea115c27e23267248/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-ocgktfp6
cwd: /tmp/pip-install-8pt10wd4/mysqlclient_5e8d8ff6d905420ea115c27e23267248/
Complete output (12 lines):
/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-8pt10wd4/mysqlclient_5e8d8ff6d905420ea115c27e23267248/setup.py", line 15, in <module>
metadata, options = get_config()
File "/tmp/pip-install-8pt10wd4/mysqlclient_5e8d8ff6d905420ea115c27e23267248/setup_posix.py", line 65, in get_config
libs = mysql_config("libs")
File "/tmp/pip-install-8pt10wd4/mysqlclient_5e8d8ff6d905420ea115c27e23267248/setup_posix.py", line 31, in mysql_config
raise OSError("{} not found".format(_mysql_config_path))
OSError: mysql_config not found
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
pip install mysql-connector-python try this , if you are still facing the issue, check your python version, make sure it is python3.8 and above.
Hello and welcome to Python! A popular library used for interacting with MySQL database servers is "PyMySQL" and this can be found at: https://pypi.org/project/PyMySQL/
Installation Command:
pip install pymysql
You can view example usage here: https://pypi.org/project/PyMySQL/#example

Error messages when i want to pip install mysql-python and mysqlclient with MacOS

I'm currently working on a project using Django with python2.7 but each time I try pip install mysqsl I get this error messages
"" ERROR: Command errored out with exit status 1:
command: 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/jb/4wfxz94x599f8rnhtgkbs92c0000gn/T/pip-install-FpxjOl/mysql-python/setup.py'"'"'; __file__='"'"'/private/var/folders/jb/4wfxz94x599f8rnhtgkbs92c0000gn/T/pip-install-FpxjOl/mysql-python/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/jb/4wfxz94x599f8rnhtgkbs92c0000gn/T/pip-install-FpxjOl/mysql-python/pip-egg-info
cwd: /private/var/folders/jb/4wfxz94x599f8rnhtgkbs92c0000gn/T/pip-install-FpxjOl/mysql-python/
Complete output (10 lines):
sh: mysql_config: command not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/jb/4wfxz94x599f8rnhtgkbs92c0000gn/T/pip-install-FpxjOl/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
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.""
Any help please
Most likely you have not installed mysql on your machine.
MySQLdb is a python interface for mysql, but it is not mysql itself. And apparently MySQLdb needs the command 'mysql_config', so you need to install that first.
You can install MySQL with brew.
xcode-select --install
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Once you have brew installed:
brew install mysql
brew link mysql
pip install MySQL-python

error when pip install mysqlclient in mac [duplicate]

This question already has answers here:
Mac OS X - EnvironmentError: mysql_config not found
(10 answers)
Closed 3 years ago.
when I try to pip install mysqlclient for python show this error
ERROR: Command errored out with exit status 1:
command: /Users/als/Desktop/Projects/sin/venv/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/30/y2trygfx15x0v9h9v8dt9dsc0000gn/T/pip-install-s44a4z2o/mysqlclient/setup.py'"'"'; __file__='"'"'/private/var/folders/30/y2trygfx15x0v9h9v8dt9dsc0000gn/T/pip-install-s44a4z2o/mysqlclient/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/30/y2trygfx15x0v9h9v8dt9dsc0000gn/T/pip-install-s44a4z2o/mysqlclient/pip-egg-info
cwd: /private/var/folders/30/y2trygfx15x0v9h9v8dt9dsc0000gn/T/pip-install-s44a4z2o/mysqlclient/
Complete output (12 lines):
/bin/sh: mysql_config: command not found
/bin/sh: mariadb_config: command not found
/bin/sh: mysql_config: command not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/30/y2trygfx15x0v9h9v8dt9dsc0000gn/T/pip-install-s44a4z2o/mysqlclient/setup.py", line 16, in <module>
metadata, options = get_config()
File "/private/var/folders/30/y2trygfx15x0v9h9v8dt9dsc0000gn/T/pip-install-s44a4z2o/mysqlclient/setup_posix.py", line 61, in get_config
libs = mysql_config("libs")
File "/private/var/folders/30/y2trygfx15x0v9h9v8dt9dsc0000gn/T/pip-install-s44a4z2o/mysqlclient/setup_posix.py", line 29, in mysql_config
raise EnvironmentError("%s not found" % (_mysql_config_path,))
OSError: mysql_config not found
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
To solve this problem just need two steps:
brew install mysql
LDFLAGS=-L/usr/local/opt/openssl/lib pip install mysqlclient

How to install mysqlclient in python?

I am new to Python, coming from Java and JS background,
I've installed Python and Pip in my local machine,
I am trying to learn Django, using MySQL,
But I am unable to install the mysqlclient using pip,
I used the following command to do so -
pip install mysqlclient
It's giving the following error -
Collecting mysqlclient
Using cached https://files.pythonhosted.org/packages/4d/38/c5f8bac9c50f3042c8f05615f84206f77f03db79781db841898fde1bb284/mysqlclient-1.4.4.tar.gz
ERROR: Command errored out with exit status 1:
command: /usr/local/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/ms/q8s67d8n09q59mbpshz3dq9m0000gn/T/pip-install-nk55db_s/mysqlclient/setup.py'"'"'; __file__='"'"'/private/var/folders/ms/q8s67d8n09q59mbpshz3dq9m0000gn/T/pip-install-nk55db_s/mysqlclient/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base pip-egg-info
cwd: /private/var/folders/ms/q8s67d8n09q59mbpshz3dq9m0000gn/T/pip-install-nk55db_s/mysqlclient/
Complete output (12 lines):
/bin/sh: mysql_config: command not found
/bin/sh: mariadb_config: command not found
/bin/sh: mysql_config: command not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/ms/q8s67d8n09q59mbpshz3dq9m0000gn/T/pip-install-nk55db_s/mysqlclient/setup.py", line 16, in <module>
metadata, options = get_config()
File "/private/var/folders/ms/q8s67d8n09q59mbpshz3dq9m0000gn/T/pip-install-nk55db_s/mysqlclient/setup_posix.py", line 61, in get_config
libs = mysql_config("libs")
File "/private/var/folders/ms/q8s67d8n09q59mbpshz3dq9m0000gn/T/pip-install-nk55db_s/mysqlclient/setup_posix.py", line 29, in mysql_config
raise EnvironmentError("%s not found" % (_mysql_config_path,))
OSError: mysql_config not found
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Screenshot -
I am solve error following process
Python 3.8.0
First install in Homebraw type following command. type this command in terminal
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install mariadb-connector-c
pip install mysqlclient
more issues follow this tutorial
https://medium.com/#MrWeeble/homebrew-on-mac-and-pythons-mysqlclient-ea44fa300e70
mysqlclient requires additional c libraires.
For linux (Debian):
$ sudo apt-get install python3-dev default-libmysqlclient-dev build-essential
For Mac:
$ brew install mysql
Further reading at the home page

Categories