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
Related
I encountered the following error while trying to install mysqlclient using the command
pip3 install mysqlclient
System information: Python 3.9, GNU/Linux Ubuntu 20.04 running on WSL
x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -Dversion_info=(2,1,1,'final',0) -D__version__=2.1.1 -I/usr/include/mysql -I/home/eweinsh/microservice/src/auth/_venv/include -I/usr/include/python3.9 -c MySQLdb/_mysql.c -o build/temp.linux-x86_64-cpython-39/MySQLdb/_mysql.o -std=c99
MySQLdb/_mysql.c:46:10: fatal error: Python.h: No such file or directory
46 | #include "Python.h"
| ^~~~~~~~~~
compilation terminated.
error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure
Initially, the error seemed to be that I hadn't install the python3 dev tools correctly, so I reinstalled python3. However, I know believe this is an issue with my installation of MySql.
I reinstalled python3 with suggested packages. I also ensured configuration files were added for mysql.
You are in a virtual environment using python 3.9 instead of python 3.8 shipped with Ubuntu 20.04 try :
sudo apt install python3.9-dev
This package installs all headers files needed to build python3.9 instead of 3.8
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'm trying to get a mysql database set up on my dreamhost shared server but it seems I can't proceed without mysqlclient. When I try pip install mysqlclient however i get
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,12,'final',0) -D__version__=1.3.12 -I/usr/include/mysql -I/usr/include/python3.4m -I/home/eptaba/aeromembers.com/AeroMembers_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:32: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
I've seen in other answers that these types of problems can be solved with
apt-get install python3.4-dev
But being on dreamhost's shared server product i'm not able to execute that command. Is there anything else I can do to either get mysqlclient or set up my mysql without it?
I got around this by installing Python 3.6 and using that in my virtualenv instead of Python 3.4. Afterwards I was able to pip install mysqlclient
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
Get sauce from github, read instructions in doc/build-unix.txt. But make can not into compile!
[urs1412#noname bitcoin]$ cd src
[urs1412#noname src]$ make -f makefile.unix
g++ -c -O2 -pthread -Wall -Wextra -Wformat -Wformat-security \
-Wno-unused-parameter -g -DBOOST_SPIRIT_THREADSAFE \
-D_FILE_OFFSET_BITS=64 -I/home/urs1412/w/bitcoin/src \
-I/home/urs1412/w/bitcoin/src/obj -DUSE_UPNP=0 -DUSE_IPV6=1 \
-I/home/urs1412/w/bitcoin/src/leveldb/include \
-I/home/urs1412/w/bitcoin/src/leveldb/helpers \
-DHAVE_BUILD_INFO -fno-stack-protector \
-fstack-protector-all -Wstack-protector \
-D_FORTIFY_SOURCE=2 -MMD -MF obj/alert.d \
-o obj/alert.o alert.cpp \
alert.cpp:6:53: fatal error: boost/algorithm/string/classification.hpp:
No such file or directory
compilation terminated.
make: *** [obj/alert.o] Error 1
td;dr could not build bitcoin, dumping system info
[urs1412#noname src]$ uname -r
3.6.10-4.fc18.x86_64
[urs1412#noname src]$ git log -n 1
commit 77a1e12eed5fc66dce16584696f54988a8c2bf4e
Merge: fe15aa3 0565b71
Author: Gavin Andresen
Date: Wed Apr 24 08:48:06 2013 -0700
Merge pull request #2554 from fanquake/qt-pro-brew-patch
bitcoin-qt.pro Brew patch
I finally was able to build bitcoin-1.8 (not the git sources, although I believe these same steps will be applicable) on my CentOS VPS.
Here are the packages I had to install. Note that I had to build some of these.
As root:
yum install gcc-c++ make
install boost-devel
yum install db4-devel
yum install openssl-devel # but this didn't provide ec.h, hence the next steps
yum install rpm-build
rpm -U ~jcomeau/rpmbuild/RPMS/x86_64/openssl-devel-1.0.0e-1.x86_64.rpm
yum install lynx # for downloading some source packages
yum install python-devel # for building miniupnpc
rpm -i ~jcomeau/rpmbuild/RPMS/x86_64/libminiupnpc9-1.8.20130503-0.1.x86_64.rpm
rpm -i ~jcomeau/rpmbuild/RPMS/x86_64/libminiupnpc-devel-1.8.20130503-0.1.x86_64.rpm
Then as user, make BOOST_LIB_SUFFIX=-mt all test
If you need instructions on building the openssl-devel (the spec file was in the sources and mostly functional) and libminiupnpc-devel (I got the spec file from an OpenSUSE source RPM and adapted it) let me know.
I believe your immediate problem is you didn't install openssl-devel. But you will likely run into these other problems after that, if you don't do some of the steps I did.
Make sure that boost library for gcc is working correctly. Try a test "hello world" program with boost. You can find it in the directory: BOOST_BUILD_PATH/example/hello
Compile it with BOOST_BUILD_PATH/bin/b2 toolset=gcc
If it doesnt work then boost is not correctly installed.