0

I have been attempting to install oursql using pip (7.1.0, I installed it using sudo easy_install pip as for my purposes the version provided by python-pip is too old) via running:

sudo pip install oursql

but this returns the error:

Collecting oursql
  Using cached oursql-0.9.3.1.tar.bz2
Building wheels for collected packages: oursql
  Running setup.py bdist_wheel for oursql
  Complete output from command /usr/bin/python -c "import setuptools;__file__='/tmp/pip-build-8AI16g/oursql/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /tmp/tmpAakYx7pip-wheel-:
  running bdist_wheel
  running build
  running build_ext
  skipping 'oursqlx/oursql.c' Cython extension (up-to-date)
  warning: no usable mysql_config and no _winreg module to try; hopefully you have usable CFLAGS/LDFLAGS set.
  building 'oursql' extension
  creating build
  creating build/temp.linux-x86_64-2.7
  creating build/temp.linux-x86_64-2.7/oursqlx
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c oursqlx/oursql.c -o build/temp.linux-x86_64-2.7/oursqlx/oursql.o
  In file included from oursqlx/oursql.c:235:0:
  oursqlx/compat.h:13:19: fatal error: mysql.h: No such file or directory
   #include "mysql.h"
                     ^
  compilation terminated.
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

  ----------------------------------------
  Failed building wheel for oursql
Failed to build oursql
Installing collected packages: oursql
  Running setup.py install for oursql
    Complete output from command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-8AI16g/oursql/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-z5NtR4-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_ext
    skipping 'oursqlx/oursql.c' Cython extension (up-to-date)
    warning: no usable mysql_config and no _winreg module to try; hopefully you have usable CFLAGS/LDFLAGS set.
    building 'oursql' extension
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c oursqlx/oursql.c -o build/temp.linux-x86_64-2.7/oursqlx/oursql.o
    In file included from oursqlx/oursql.c:235:0:
    oursqlx/compat.h:13:19: fatal error: mysql.h: No such file or directory
     #include "mysql.h"
                       ^
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    ----------------------------------------
Command "/usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-8AI16g/oursql/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-z5NtR4-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-8AI16g/oursql

I have tried to follow this guide, but I hadn't the foggiest what I was meant to do with the MYSQL_CONFIG variable as I have no idea what it should be set to. I also attempted running: sudo easy_install oursql to install oursql but it too failed, giving:

/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py:2512: 
PEP440Warning: 'python-apt (0.9.3.11build1)' is being parsed as a legacy, non PEP 440, version. You may find odd behavior and sort order. In particular it will be sorted as less than 0.0. It is recommend to migrate to PEP 440 compatible versions.
  PEP440Warning,
/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py:2512: PEP440Warning: 'PyECLib (1.0.5m)' is being parsed as a legacy, non PEP 440, version. You may find odd behavior and sort order. In particular it will be sorted as less than 0.0. It is recommend to migrate to PEP 440 compatible versions.
  PEP440Warning,
/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py:2512: PEP440Warning: 'pygame (1.9.1release)' is being parsed as a legacy, non PEP 440, version. You may find odd behavior and sort order. In particular it will be sorted as less than 0.0. It is recommend to migrate to PEP 440 compatible versions.
  PEP440Warning,
Searching for oursql
Reading https://pypi.python.org/simple/oursql/
Reading http://launchpad.net/oursql
Best match: oursql 0.9.3.1
Downloading https://pypi.python.org/packages/source/o/oursql/oursql-0.9.3.1.zip#md5=ad599ea2d95fc695df7195e9801b45c2
Processing oursql-0.9.3.1.zip
Writing /tmp/easy_install-gejSuT/oursql-0.9.3.1/setup.cfg
Running oursql-0.9.3.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-gejSuT/oursql-0.9.3.1/egg-dist-tmp-N9kmGB
warning: no usable mysql_config and no _winreg module to try; hopefully you have usable CFLAGS/LDFLAGS set.
In file included from oursqlx/oursql.c:235:0:
oursqlx/compat.h:13:19: fatal error: mysql.h: No such file or directory
 #include "mysql.h"
                   ^
compilation terminated.
error: Setup script exited with error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
  • 3
    It looks like you're missing mysql.h which comes from the libmysqlclient-dev package. – Timo Aug 21 '15 at 11:08
2

I found the solution myself, the guide I was following led me to believe that pip would do all the work for me (i.e., install all the necessary dependencies) but I needed to install the MySQL Connector C++ libraries (Ubuntu package name: libmysqlcppconn-dev). So I ran sudo apt-get install libmysqlcppconn-dev to install this package and afterwards sudo pip install oursql ran without error. So Timo's comment was on the right track.

0

Install oursql in macOS.

So, here's the standard solution to be able to install oursql correctly in macOS.

brew install mysql@5.7

Now, follow all the instructions given at the end of the installation.

To run the secure installation(set password etc.), you'll need to go here and run /usr/local/mysql@5.7/bin/mysql_secure_installation

Now, once we have mysql installed, there are some dependency of the ourselves package like mysql-client. You can install it with below command:

brew install mysql-client

After the installation follow the setup instructions given at the end of installation.

Don't forget to reload bash here. source ~/.bash_profile

Now, restart the mysql by brew service restart mysql

Now, at last first install mysqlclient with pip and then install oursql.

pip install mysqlclient
pip install oursql

All Good!

  • Are you aware this is AskUbuntu not AskmacOS (which doesn't exist, I know, making a point)? Hence I'm not asking how to do so on macOS, rather Ubuntu. – BH2017 Oct 24 '18 at 8:14
  • Just like many users, I was redirected to this thread after many searches. So, I figured that this answer might help those in need. Otherwise Yes, I'm aware of this is AskUbuntu. – Jay Modi Oct 24 '18 at 9:00
0

I just had a similar issue installing oursql in a virtualenv.

My output included a similar error to this part below (from the question):

  oursqlx/compat.h:13:19: fatal error: mysql.h: No such file or directory
   #include "mysql.h"
                     ^
  compilation terminated.

Which led me to the solution in the accpeted answer of this stackoverflow question.

sudo apt install libmysqlclient-dev fixed the issue in my case.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.