I'm trying to install mysqlclient to connect to my database with django, but get the following error:
(venv) dhcp-ccc-12919:project user$ pip3 install mysqlclient
Collecting mysqlclient
Using cached https://files.pythonhosted.org/packages/6f/86/bad31f1c1bb0cc99e88ca2adb7cb5c71f7a6540c1bb001480513de76a931/mysqlclient-1.3.12.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/l4/0f1p1xlj3hlbxr6rzgqzrxmh0000gn/T/pip-install-lo7y8khq/mysqlclient/setup.py", line 17, in <module>
metadata, options = get_config()
File "/private/var/folders/l4/0f1p1xlj3hlbxr6rzgqzrxmh0000gn/T/pip-install-lo7y8khq/mysqlclient/setup_posix.py", line 54, in get_config
libraries = [dequote(i[2:]) for i in libs if i.startswith('-l')]
File "/private/var/folders/l4/0f1p1xlj3hlbxr6rzgqzrxmh0000gn/T/pip-install-lo7y8khq/mysqlclient/setup_posix.py", line 54, in <listcomp>
libraries = [dequote(i[2:]) for i in libs if i.startswith('-l')]
File "/private/var/folders/l4/0f1p1xlj3hlbxr6rzgqzrxmh0000gn/T/pip-install-lo7y8khq/mysqlclient/setup_posix.py", line 12, in dequote
if s[0] in "\"'" and s[0] == s[-1]:
IndexError: string index out of range
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/l4/0f1p1xlj3hlbxr6rzgqzrxmh0000gn/T/pip-install-lo7y8khq/mysqlclient/
I have the following in my settings.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'todo',
'USER': 'root',
'PASSWORD': 'password'
}
}
If you see the document of mysqlclient, I think it make mighty help for you.
The document say:
Note that this is a basic step. I can not support complete step for build for all environment. If you can see some error, you should fix it by yourself, or ask for support in some user forum. Don't file a issue on the issue tracker.
You may need to install the Python 3 and MySQL development headers and libraries like so:
$ sudo apt-get install python3-dev default-libmysqlclient-dev build-essential # Debian / Ubuntu
$ sudo yum install python3-devel mysql-devel # Red Hat / CentOS
Then you can install mysqlclient via pip now:
$ pip install mysqlclient
If you are on windows,
you can install mysqlclient using wheel from here.
Donwload the appropriate file as per your platform; for eg: if you are using python 3.6 and 32 bit python then download
mysqlclient‑1.3.13‑cp36‑cp36m‑win32.whl
After downloading it, copy it in C:/
Then install the file using following code:
pip3 install C:\mysqlclient‑1.3.13‑cp36‑cp36m‑win32.whl\
If you are using a virtual environment, then activate your virtual env before installing.
brew install mysql
fixed this for me
Please visit the following link which contains working pip installations for different os:
https://github.com/prasad01dalavi/python_packages_installations
for python2 in linux
sudo apt-get install -y python-dev libmysqlclient-dev && sudo pip install mysqlclient
Related
I'm on OSX El Capitan, using Python 2.7 (Anaconda). Launching the command pip install MySQL-python yields:
Collecting MySQL-python
Using cached MySQL-python-1.2.5.zip
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/d2/gd004m2s35z5dlyz9mfn6sc40000gn/T/pip-build-FYvb_T/MySQL-python/setup.py", line 17, in <module>
metadata, options = get_config()
File "setup_posix.py", line 53, in get_config
libraries = [ dequote(i[2:]) for i in libs if i.startswith(compiler_flag("l")) ]
File "setup_posix.py", line 8, in dequote
if s[0] in "\"'" and s[0] == s[-1]:
IndexError: string index out of range
None of these worked (exit with same error).
pip install mysqlclient
easy_install MySQL-python
pip is up-to-date. I've basically tried to follow all suggestions in related questions, but none succeeded. Any help is appreciated, thanks!
Copy from this blog.
By finding out the information that mysql-connector-cmight come to the conclusion that the configuration by brew installation may be incorrect , open the /usr/local/bin/mysql_config script to modify some of the contents of it:
#Create options
Libs = "-L$pkglibdir "
Libs = "$libs -l"
change into:
#Create options
Libs = "-L$pkglibdir"
Libs = "$libs -lmysqlclient -lssl -lcrypto"
Save
Then re-install mysql-python:
pip install mysql-python
I met same error and solved with following instructions:
brew uninstall mysql-connector-c
brew install mysql
invoke "mysql_config --libs" and confirm its output include correct library options: "-L/usr/local/Cellar/mysql/5.7.20/lib -lmysqlclient -lssl -lcrypto"
export LDFLAGS=-L/usr/local/opt/openssl/lib && pip install mysqlclient
This solved my issue:
brew install mysql#5.7
brew link --force mysql#5.7
I got the same error while installing pip install MySql-python.
Then, I had installed libmysqlclient-dev using the command:
sudo apt install libmysqlclient-dev
After installing it, I tried again and pip install MySql-python
and it worked for me.
I am using python3 to install mysql-python package. So, when I run
pip install mysql-python,
it gives me error.
Tried using
pip install --upgrade setuptools
It shows
Collecting mysql-python
Using cached https://files.pythonhosted.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-tu6ygqzj/mysql-python/setup.py", line 13, in <module>
from setup_posix import get_config
File "/tmp/pip-build-tu6ygqzj/mysql-python/setup_posix.py", line 2, in <module>
from ConfigParser import SafeConfigParser
**ImportError: No module named 'ConfigParser'**
----------------------------------------
***Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-tu6ygqzj/mysql-python/***
Successfully installed with all files in it.
I guess you need to install the following:
pip install mysqlclient
In Python 3, ConfigParser has been renamed to configparser for PEP 8 compliance.
mysqlclient is a fork of mysql-python, with Python 3 support.
Kindly make sure you have installed the following before installing mysqlclient:
sudo apt-get install python3-dev libmysqlclient-dev
For Lunix and Mac Machines, install the mysqlclient pre-requisites via:
Debian / Ubuntu - sudo apt-get install python-dev default-libmysqlclient-dev
Red Hat / CentOS - sudo yum install python-devel mysql-devel
macOS (Homebrew) - brew install mysql-client
I tried to do this before that so after this it command work:
apt-get install libmysqlclient-dev
Trying to install from pipenv with:
pipenv install mysqlclient
will reseult in:
Installing mysqlclient… Collecting mysqlclient Using cached
https://files.pythonhosted.org/packages/6f/86/bad31f1c1bb0cc99e88ca2adb7cb5c71f7a6540c1bb001480513de76a931/mysqlclient-1.3.12.tar.gz
Complete output from command python setup.py egg_info:
/bin/sh: 1: mysql_config: not found
Traceback (most recent call last):
File "", line 1, in
File "/tmp/pip-install-5vhtqgve/mysqlclient/setup.py", line 17, in
metadata, options = get_config()
File "/tmp/pip-install-5vhtqgve/mysqlclient/setup_posix.py", line 44, in get_config
libs = mysql_config("libs_r")
File "/tmp/pip-install-5vhtqgve/mysqlclient/setup_posix.py", line 26, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
OSError: mysql_config not found
----------------------------------------
Error: An error occurred while installing mysqlclient! Command
"python setup.py egg_info" failed with error code 1 in
/tmp/pip-install-5vhtqgve/mysqlclient/
This is likely caused by a bug in mysqlclient. Report this to its
maintainers.
I'm using a Debian and with another virtualenv it get the system package
python-mysqldb/testing,now 1.3.10-1 amd64
Pipenv won't use this one and won't install the other.
How can I solve this?
Thanks,BR
You probably need the mysql client lib for the OS.
sudo apt install libmysqlclient-dev
Then you should be able to:
pipenv install mysqlclient
I fixed that problem with the following command:
brew install mysql
First install python-dev
sudo apt-get install python3-dev
and then install mysqlclient-dev version
sudo apt-get install python3-dev libmysqlclient-dev
I would recommend you to install the file first.
On windows I used
pip install "mysqlclient-1.3.13-cp35-cp35m-win_amd64.whl"
and the tried:
pip install mysqlclient.
It worked well.
if you are on Centos
Try: yum install mariadb-devel
this package includes the missing mysql-config
Try:
sudo apt-get install libmysqlclient-dev
and then:
sudo apt-get install libmariadbclient-dev
What might be the problem below? It looks like there is a bug in pip.
I installed pip yesterday using brew. Prior to that, I had installed
most python packages with $ python setup.py install
steves-MacBook-Pro:server steve$ pip -V
pip 1.4.1 from /Library/Python/2.7/site-packages/pip-1.4.1-py2.7.egg (python 2.7)
steves-MacBook-Pro:server steve$ pip list
altgraph (0.9)
bdist-mpkg (0.4.4)
...
...(a bunch of python packages omitted here for brevity)
...
...
requests (2.0.0)
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-1.4.1-py2.7.egg/pip/basecommand.py", line 134, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip-1.4.1-py2.7.egg/pip/commands/list.py", line 80, in run
self.run_listing(options)
File "/Library/Python/2.7/site-packages/pip-1.4.1-py2.7.egg/pip/commands/list.py", line 127, in run_listing
self.output_package_listing(installed_packages)
File "/Library/Python/2.7/site-packages/pip-1.4.1-py2.7.egg/pip/commands/list.py", line 136, in output_package_listing
if dist_is_editable(dist):
File "/Library/Python/2.7/site-packages/pip-1.4.1-py2.7.egg/pip/util.py", line 347, in dist_is_editable
req = FrozenRequirement.from_dist(dist, [])
File "/Library/Python/2.7/site-packages/pip-1.4.1-py2.7.egg/pip/__init__.py", line 194, in from_dist
assert len(specs) == 1 and specs[0][0] == '=='
AssertionError
Using modern Ubuntu, I had the same problem and was able to fix it using the instructions in this comment.
The problem, as I understand it, is that pip as provided by Ubuntu is old, and also cannot update itself (since it's managed by apt, not pip). One solution is to remove the Ubuntu version of pip and install the latest.
In short:
sudo apt-get remove python-pip
wget https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py
This will install pip to /usr/local/bin, so you'll want to add that to your path.
This can be caused by an old version of pip.
Make sure your setuptools and pip are up to date:
sudo pip install --upgrade setuptools
sudo pip install --upgrade pip
I'm using a clean instance of Ubuntu server and would like to install some python packages in my virtualenv.
I receive the following output from the command 'pip install -r requirements.txt'
Downloading/unpacking pymongo==2.5.2 (from -r requirements.txt (line 7))
Downloading pymongo-2.5.2.tar.gz (303kB): 303kB downloaded
Running setup.py egg_info for package pymongo
Traceback (most recent call last):
File "<string>", line 3, in <module>
ImportError: No module named setuptools.command
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 3, in <module>
ImportError: No module named setuptools.command
----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /home/redacted/env/build/pymongo
Storing complete log in /home/redacted/.pip/pip.log
Any Idea what's going on?
python version 2.7.3
pip version pip 1.4 from /home/redacted/env/lib/python2.7/site-packages (python 2.7)
Try installing:
sudo apt-get install python-setuptools
if this doesn't work try:
curl -O https://bootstrap.pypa.io/get-pip.py
python get-pip.py
Edit: If you have several (possible conflicting) python installations or environments, the following commands can be useful to debug which executables are being used:
which python
which pip
which easy_install
They should "match". It can happen for example that you have pip installing packages for an EPD or global distribution while the current python that is being used corresponds to a local environment (or something different), in which case it might not be able to see the installed packages.
had the same problem, solved it with
pip install -U setuptools
Elaborating #elyase's Answer.
First check for which python version you want to install setuptools.
Normally both python versions comes default with debian or any linux distro.
So, as per your requirement install setup tools using apt package manager
For python 2.x
sudo apt-get install python-setuptools
For python 3.x
sudo apt-get install python3-setuptools
These instructions solved the problem for me:
first enter these commands
pip install --upgrade pip
pip install --upgrade wheel
pip install setuptools
and then try to install the package that requires setuptools.