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
Related
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
While installing a package in R, I am getting error message in mu ubuntu 16.04 machine as shown belo dur t lack of tcl/tlk header. How to resolve it?
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I/usr/include/tcl8.6 -I/usr/include/tcl8.6 -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c tcltkimg.c -o tcltkimg.o
tcltkimg.c:2:16: fatal error: tk.h: No such file or directory
You need to add the tk-dev package to your system (e.g., with apt-get) as that contains the tk.h file; the command line invocation you need is (probably):
sudo apt-get install tk-dev
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
I've never used the ARCHFLAGS command before and am in way over my head.
I'm struggling with getting the MySQL gem working on Snow Leopard in 64 bit.
What I'm doing is this command:
sudo env ARCHFLAGS='-arch x86_64' gem install --verbose --no-rdoc --no-ri mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
The output looks like this:
.....
make
gcc -I. -I. -I/usr/local/lib/ruby/1.8/universal-darwin8.0 -I. -DHAVE_RB_THREAD_START_TIMER -DHAVE_MYSQL_H -I/usr/local/mysql/include/mysql -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT -DDONT_DECLARE_CXA_PURE_VIRTUAL -fno-common -g -O2 -fno-common -pipe -fno-common -arch i386 -c mysql.c
cc -dynamic -bundle -undefined suppress -flat_namespace -arch i386 -L"/usr/local/lib" -o mysql_api.bundle mysql.o -lruby -L/usr/local/mysql/lib/mysql -lmysqlclient -lz -lm -lpthread -ldl -lobjc
ld: warning: in /usr/local/mysql/lib/mysql/libmysqlclient.dylib, file is not of required architecture
make install
/usr/bin/install -c -m 0755 mysql_api.bundle /usr/local/lib/ruby/gems/1.8/gems/mysql-2.8.1/lib
Successfully installed mysql-2.8.1
1 gem installed
What I see is that it specifically specifies -arch i386 even though I'm telling it not to; directly after, it gives me the warning about the file not being the required architecture, because it's not. It's 64 bit.
Running the file command gives this:
file /usr/local/mysql/lib/mysql/libmysqlclient.dylib
/usr/local/mysql/lib/mysql/libmysqlclient.dylib: Mach-O 64-bit dynamically linked shared library x86_64
So of course it's not the required architecture. It seems that the gem install is ignoring my ARCHFLAGS command. Any idea why this would be? Like I said, I'm in way over my head on this stuff :P
Thanks so much all! - Kevin
Here's what I did:
export ARCHFLAGS="-arch x86_64"
sudo gem install --no-rdoc --no-ri mysql -v 2.7 -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
I specified version 2.7 because there seemed to be a problem with subsequent versions. I'd try the latest version and see if it works first.
Have you reviewed the comments at Rails + MySQL on Snow Leopard
There is a lot of discussion around the setup and installation which may assist. I build the MySQL binaries from source following advice from Build MySQL on Snow Leopard.
First I wanted to build the DBD::mysql package. That kept failing because whatever make resulted in could not be loaded for the tests with a Symbol not found: _is_prefix. So I assumed that cpan might be a tad old. I know it's a random assumption, but cpan did tell me to install the latest Bundle::CPAN.
Who's successfully installed either DBD::mysql or Bundle::CPAN on Mac OS X 10.5? Could you recommend any thing I could be doing differently?
This is perl, v5.8.8 built for darwin-thread-multi-2level
(with 4 registered patches, see perl -V for more detail)
/usr/local/mysql/bin/mysql Ver 14.14 Distrib 5.1.36,
for apple-darwin9.5.0 (i386) using readline 5.1
Here's a log of the CPAN output for DBD::mysql:
Writing Makefile for DBD::mysql
cc -c -I/Library/Perl/5.8.8/darwin-thread-multi-2level/auto/DBI -I/usr/local/mysql/include -DDBD_MYSQL_INSERT_ID_IS_GOOD -g -arch ppc -arch i386 -g -pipe -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -Wdeclaration-after-statement -I/usr/local/include -O3 -DVERSION=\"4.012\" -DXS_VERSION=\"4.012\" "-I/System/Library/Perl/5.8.8/darwin-thread-multi-2level/CORE" dbdimp.c
/usr/bin/perl -p -e "s/~DRIVER~/mysql/g" /Library/Perl/5.8.8/darwin-thread-multi-2level/auto/DBI/Driver.xst > mysql.xsi
Running Mkbootstrap for DBD::mysql ()
chmod 644 mysql.bs
/usr/bin/perl /System/Library/Perl/5.8.8/ExtUtils/xsubpp -typemap /System/Library/Perl/5.8.8/ExtUtils/typemap mysql.xs > mysql.xsc && mv mysql.xsc mysql.c
cp lib/DBD/mysql.pm blib/lib/DBD/mysql.pm
cp lib/DBD/mysql/GetInfo.pm blib/lib/DBD/mysql/GetInfo.pm
cp lib/DBD/mysql/INSTALL.pod blib/lib/DBD/mysql/INSTALL.pod
cp lib/Bundle/DBD/mysql.pm blib/lib/Bundle/DBD/mysql.pm
cp mysql.bs blib/arch/auto/DBD/mysql/mysql.bs
chmod 644 blib/arch/auto/DBD/mysql/mysql.bs
Warning: duplicate function definition 'do' detected in mysql.xs, line 225
Warning: duplicate function definition 'rows' detected in mysql.xs, line 650
cc -c -I/Library/Perl/5.8.8/darwin-thread-multi-2level/auto/DBI -I/usr/local/mysql/include -DDBD_MYSQL_INSERT_ID_IS_GOOD -g -arch ppc -arch i386 -g -pipe -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -Wdeclaration-after-statement -I/usr/local/include -O3 -DVERSION=\"4.012\" -DXS_VERSION=\"4.012\" "-I/System/Library/Perl/5.8.8/darwin-thread-multi-2level/CORE" mysql.c
dbdimp.c: In function 'mysql_describe':
dbdimp.c:3309: warning: assignment from incompatible pointer type
dbdimp.c: In function 'mysql_describe':
dbdimp.c:3309: warning: assignment from incompatible pointer type
rm -f blib/arch/auto/DBD/mysql/mysql.bundle
LD_RUN_PATH="/usr/local/mysql/lib" /usr/bin/perl myld cc -mmacosx-version-min=10.5.7 -arch ppc -arch i386 -bundle -undefined dynamic_lookup -L/usr/local/lib dbdimp.o mysql.o -o blib/arch/auto/DBD/mysql/mysql.bundle \
-L/usr/local/mysql/lib -lmysqlclient -lz -lm \
chmod 755 blib/arch/auto/DBD/mysql/mysql.bundle
Manifying blib/man3/DBD::mysql.3pm
Manifying blib/man3/DBD::mysql::INSTALL.3pm
Manifying blib/man3/Bundle::DBD::mysql.3pm
CAPTTOFU/DBD-mysql-4.012.tar.gz
/usr/bin/make -j3 -j3 -- OK
Running make test
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/00base.t .................. 1/6 Bailout called. Further testing stopped: Unable to load DBD::mysql
# Failed test 'use DBD::mysql;'
# at t/00base.t line 21.
# Tried to use 'DBD::mysql'.
# Error: Can't load '/Users/dlamblin/.cpan/build/DBD-mysql-4.012-4n3pv8/blib/arch/auto/DBD/mysql/mysql.bundle' for module DBD::mysql: dlopen(/Users/dlamblin/.cpan/build/DBD-mysql-4.012-4n3pv8/blib/arch/auto/DBD/mysql/mysql.bundle, 2): Symbol not found: _is_prefix
# Referenced from: /Users/dlamblin/.cpan/build/DBD-mysql-4.012-4n3pv8/blib/arch/auto/DBD/mysql/mysql.bundle
# Expected in: dynamic lookup
# at (eval 7) line 2
# Compilation failed in require at (eval 7) line 2.
# BEGIN failed--compilation aborted at (eval 7) line 2.
FAILED--Further testing stopped: Unable to load DBD::mysql
make: *** [test_dynamic] Error 255
CAPTTOFU/DBD-mysql-4.012.tar.gz
/usr/bin/make test -- NOT OK
//hint// to see the cpan-testers results for installing this module, try:
reports CAPTTOFU/DBD-mysql-4.012.tar.gz
Running make install
make test had returned bad status, won't install without force
Failed during this command:
CAPTTOFU/DBD-mysql-4.012.tar.gz : make_test NO
Okay, if you get these errors I now know the following:
MySQL 5.1 for Mac OS X x86_64 is not compatible with DBD::mysql (yet). Install the 32-bit x86 version, and try again. You'll succeed. I wish the perl Makefile.pl would just tell you that in a banner.
Bundle::CPAN had issues because I wasn't installing as root. Why that makes it report circular references instead of installation permission issues, I'll never understand.
Please add a comment if and when this became outdated information.
Installing the (beta) 5.4.1 64 bit version of mysql, available from their developer website, fixes the issue. Tested on Snow Leopard.
Did you try installing Bundle::DBD::mysql?
I haven't dealt with this problem, but I found that MacPorts cleaned up all my UNIX incompatibility problems. You might want to try that before enduring too much pain and suffering.
Where is it complaining about a circular dependency? It looks like you are trying to link to an incompatible version of the mysql libraries. The symbol it's looking for isn't in the library you loaded. I don't think this is a problem caused by CPAN.pm or the cpan script.
Some questions:
Who compiled perl? Is this Apple's perl?
Who compiled mysql? Is that your own version since it's in /usr/local?
Did you previously compile other versions? I start with a compile to ensure everything points to the right places.
Installing latest beta 64bit version of Mysql fixed problem on my computer.