I installed django 1.8.5 in virtualenv and using python 3.4.3
the worked displayed the it works page when using sqlite
I wanted to use mysql and I'm trying to install mysqlclient using
pip install mysqlclient
and I'm getting the following message
----------------------------------------
Failed building wheel for mysqlclient
Failed to build mysqlclient
Installing collected packages: mysqlclient
Running setup.py install for mysqlclient
Complete output from command /home/sasidhar/django/env/bin/python3 -c "import setuptools, tokenize;__file__='/tmp/pip-build-5lj39q67/mysqlclient/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-da2_35zs-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/sasidhar/django/env/include/site/python3.4/mysqlclient:
running install
running build
running build_py
copying MySQLdb/release.py -> build/lib.linux-x86_64-3.4/MySQLdb
running build_ext
building '_mysql' extension
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -Dversion_info=(1,3,6,'final',1) -D__version__=1.3.6 -I/usr/include/mysql -I/usr/include/python3.4m -I/home/sasidhar/django/env/include/python3.4m -c _mysql.c -o build/temp.linux-x86_64-3.4/_mysql.o -DBIG_JOINS=1 -fno-strict-aliasing -g -DNDEBUG
_mysql.c:40:20: fatal error: Python.h: No such file or directory
#include "Python.h"
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Command "/home/sasidhar/django/env/bin/python3 -c "import setuptools, tokenize;__file__='/tmp/pip-build-5lj39q67/mysqlclient/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-da2_35zs-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/sasidhar/django/env/include/site/python3.4/mysqlclient" failed with error code 1 in /tmp/pip-build-5lj39q67/mysqlclient
I did try installing libraries suggested in error: Setup script exited with error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
and still the problem persists
please help me solve this problem
Thanks guys!!
You need to install python-dev:
sudo apt-get install python-dev
And, since you are using python3:
sudo apt-get install python3-dev
This command should help you.
If you are using mac os you might try:
brew update && brew rm python3 && brew install python3
You need to brew has been installed already, otherwise you can install it. It is very useful for getting packages in Mac OS. http://brew.sh/
For Ubuntu you also need to install build-essential
sudo apt-get install build-essential
For those using different versions, such as Python 3.5, 3.6 or 3.7 I found this:
Part I
For Python 2.x use:
$ sudo apt-get install python-dev
For Python 2.7 use:
$ sudo apt-get install libffi-dev
For Python 3.x use:
$ sudo apt-get install python3-dev
For Python 3.4 use:
$ sudo apt-get install python3.4-dev
For Python 3.7 use:
$ sudo apt-get install python3.7-dev
Part II
If this still doesn't help, others have pointed out to install
$ sudo apt-get install build-essential
and finally
$ sudo apt-get install libssl-dev
But the last two didn't help me personally. Just in case, hope it helps you.
For those using python3.5:
apt-get install python3.5-dev
wget https://bootstrap.pypa.io/get-pip.py
python3.5 get-pip.py
pip3.5 install mysqlclient
Tried all of the above suggestions and a few found elsewhere and nothing worked. In the end the solution was simple enough (courtesy of ignacionf on GitHub):
pip install git+https://github.com/PyMySQL/mysqlclient-python.git
Related
I installed Python 2.7.15rci and Python 3.6.7 on Ubuntu. When i did 'pip list' on virtualenv it returns me:
Django (2.1.5)
pip (9.0.1)
pkg-resources (0.0.0)
pytz (2018.9)
setuptools (39.0.1)
wheel (0.32.3)
I'm trying to install mysqlclient (pip install mysqlclient) and returns an error.
unable to execute 'x86_64-linux-gnu-gcc': No such file or directory
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Failed building wheel for mysqlclient
Running setup.py clean for mysqlclient
Failed to build mysqlclient
Installing collected packages: mysqlclient
Running setup.py install for mysqlclient ... error
Complete output from command /home/david/env/project/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-pq18uxjj/mysqlclient/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-y28h4ou0-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/david/env/project/include/site/python3.6/mysqlclient:
/usr/lib/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'long_description_content_type'
warnings.warn(msg)
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/__init__.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/_exceptions.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/compat.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/connections.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/converters.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/cursors.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/release.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/times.py -> build/lib.linux-x86_64-3.6/MySQLdb
creating build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
running build_ext
building 'MySQLdb._mysql' extension
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/MySQLdb
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Dversion_info=(1,4,1,'final',0) -D__version__=1.4.1 -I/usr/include/mysql -I/home/david/env/project/include -I/usr/include/python3.6m -c MySQLdb/_mysql.c -o build/temp.linux-x86_64-3.6/MySQLdb/_mysql.o
unable to execute 'x86_64-linux-gnu-gcc': No such file or directory
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Command "/home/david/env/project/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-pq18uxjj/mysqlclient/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-y28h4ou0-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/david/env/project/include/site/python3.6/mysqlclient" failed with error code 1 in /tmp/pip-build-pq18uxjj/mysqlclient/
So, I have tried different methods found like:
sudo apt-get install python-dev
sudo apt-get install python3-dev
sudo apt-get install libmysqlclient-dev
and some more... but none of them work for me and the problem persists.
Any suggestions?
Thank you!
gcc is part of the build-essential package, which you should install before anything else:
sudo apt-get install build-essential
UPDATE: Following #bosnjak's suggestion, you also might need to install the openssl developer tools:
sudo apt-get install libssl-dev
I specified the particular version of python it's 3.7
And that helped me
I have installed these ones:
sudo apt-get install python3.7-dev libmysqlclient-dev
And then installed mysqlclient by:
pip install mysqlclient
I turned out, that the solution is slightly different for almost every Python version. For those using different versions, such as Python 2.x, 3.5 or 3.7 I found this:
Part I
For Python 2.x use:
$ sudo apt-get install python-dev
For Python 2.7 use:
$ sudo apt-get install libffi-dev
For Python 3.x use:
$ sudo apt-get install python3-dev
For Python 3.4 use:
$ sudo apt-get install python3.4-dev
For Python 3.7 use:
$ sudo apt-get install python3.7-dev
For Python 3.8 use:
$ sudo apt-get install python3.8-dev
For Python 3.9 use:
$ sudo apt-get install python3.9-dev
Part II
If this still doesn't help, others have pointed out to install
$ sudo apt-get install build-essential
and finally
$ sudo apt-get install libssl-dev
But the last two didn't help myself - but hoping this might help you!
You may do this before:
sudo apt-get install python3-dev default-libmysqlclient-dev build-essential
Source: https://pypi.org/project/mysqlclient/
This issue was persistent in Ubuntu and python 3+. In my case, I was using Ubuntu 18.04 and found this solution to be useful for python version 3.7.5
Step 1. Install libpython3.7-dev via sudo apt
> sudo apt-get install libpython3.7-dev
Step 2: Install mysqlclient
> python3 -m pip install mysqlclient==1.4.6
I wanted to install the 'Modoboa' mail-server package (https://github.com/modoboa/modoboa) on my Ubuntu 18.04 with Apache as my webserver, instead of nginx. I needed mysqlclient for Python 2.7. The following packages worked for me:
sudo apt-get install libssl-dev gcc python2.7-dev libmysqlclient-dev
I'm using the python3.8. Similarly to david's answer, use the following command then it works.
$ sudo apt-get install python3.8-dev
I got following error when I am trying to install python-igraph using sudo pip install python-igraph
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-ZHOdbM/python-igraph/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-MGaN23-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-ZHOdbM/python-igraph/
I also try to install C core using the link given in the answer UnicodeDecodeError when installing python-igraph
I would suggest you to use conda and the following command :
conda install -c conda-forge python-igraph
https://anaconda.org/conda-forge/python-igraph
On Mac OS Sierra, created virtualenv using python2.7 and trying to install mysqlclient to use Django w/ MySQL. I installed MySQL 5.6 via homebrew. Running "pip install mysqlclient" gives these errors:
Running setup.py bdist_wheel for mysqlclient ... error
...
13 warnings generated.
cc -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -Wl,-F. build/temp.macosx-10.12-intel-2.7/_mysql.o -L/usr/local/Cellar/mysql56/5.6.32/lib -lmysqlclient -lssl -lcrypto -o build/lib.macosx-10.12-intel-2.7/_mysql.so
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'cc' failed with exit status 1
Failed building wheel for mysqlclient
Command "...env2.7/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/nm/mqfwjt115q7g0lpvnx7sylwm0000gn/T/pip-build-tJmAVS/mysqlclient/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/nm/mqfwjt115q7g0lpvnx7sylwm0000gn/T/pip-xVuIu1-record/install-record.txt --single-version-externally-managed --compile --install-headers .../env2.7/include/site/python2.7/mysqlclient" failed with error code 1 in /private/var/folders/nm/mqfwjt115q7g0lpvnx7sylwm0000gn/T/pip-build-tJmAVS/mysqlclient/
Any help would be greatly appreciated.
The answer was installing dev tools using:
xcode-select --install
In my case I needed to do two steps:
xcode-select --install
as #howevilweare says AND also pip install with the brew installed openssl using an env command:
env LDFLAGS="-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib" pip install mysqlclient
The error is -
Loading command: install (LoadError) cannot load such file -- zlib
ERROR: While executing gem ... (NoMethodError) undefined method
`invoke_with_build_args' for nil:NilClass
Please tell the possible reason for this error and help in resoving it.
The same problem is discussed here. It is also solved. Their findings might help you:
https://github.com/jekyll/jekyll-help/issues/55
From the link:
Great! It's all working! I followed this steps:
First i removed all previously installed rubies on my OS.
And next this:
sudo apt-get update
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties
sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev
curl -L https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
echo "source ~/.rvm/scripts/rvm" >> ~/.bashrc
rvm install 2.1.2
rvm use 2.1.2 --default
gem install jekyll
I wanted to try sqlalchemy for my code but in order to use it I need first to install mysql-python. I downloaded the package but when I tried {python setup.py install} it gives me an error that I cannot understand.
running build
running build_py
copying MySQLdb/release.py -> build/lib.linux-i686-2.7/MySQLdb
running build_ext
building '_mysql' extension
i686-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -Dversion_info=(1,2,4,'beta',4) -D__version__=1.2.4b4 -I/usr/include/mysql -I/usr/include/python2.7 -c _mysql.c -o build/temp.linux-i686-2.7/_mysql.o -DBIG_JOINS=1 -fno-strict-aliasing -g -DNDEBUG
_mysql.c:29:20: fatal error: Python.h: No such file or directory
compilation terminated. error: command 'i686-linux-gnu-gcc' failed with exit status 1
after sudo apt-get install python2.7-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
python2.7-dev : Depends: libpython2.7-dev (= 2.7.4-2ubuntu3.2) but it is not going to be installed
Depends: libexpat1-dev but it is not installable
E: Unable to correct problems, you have held broken packages.
If it is for python 3.6, you have to install corresponding python3-dev, i.e:
sudo apt-get install python3.6-dev
You probably haven't installed python-dev, so I would suggest you to run
sudo apt-get install python-dev
Source: Python.h missing from Ubuntu 12.04
try this out:
sudo apt-get install zlib1g-dev