2

I'm getting an error after installing MySQL Connector for Python 2.7.9 in Linux OS.

Command /usr/bin/python -c "import setuptools, tokenize;file='/tmp/pip-build-5nxFZ_/mysql-connector-python-rf/setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record /tmp/pip-qLvsiw-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip-build-5nxFZ_/mysql-connector-python-rf

Storing debug log for failure in /home/pi/.pip/pip.log

Searched a lot about this error couldn't find a satisfactory solution, please help me to sort out this error.

Thank you. :)

4 Answers 4

2

use

pip install mysqlclient

as Mysql-Python and all are not supported now. install mysql in linux and install the connector to connect to local mysql

Sign up to request clarification or add additional context in comments.

6 Comments

Thank You @Exprator by using the above command I connected successfully to local Mysql but getting an error while connecting to remote Mysql server. "Remote Host is CentOS, tried giving grant permission in remote host by got an error as OperationalError "
for that you need to give permission to the remote host so that it can connect from other port, anyways i see you already accepted someones answer, hope you can connect to remote too :)
No, by using above comments I can connect to local MySQL server, not to remote MySQL server.
so the answer you accepted is allowing you to connect to the remote server? else you need to open the port of the centos for incoming requests
Oh sorry, I didn't check the port in centOS. Thank you :)
|
2

try this ,

pip install MySQL-python==1.2.5  # version specified

or

pip install MySQL-python

3 Comments

Thank you, I tried it but got an error like this "Command python setup.py egg_info failed with error code 1 in /tmp/pip-build-cCkNRE/MySQL-python Storing debug log for failure in /home/pi/.pip/pip.log"
check your pip.log what is the error occurs. seems pip need update
Updated PIP and can connect to local Mysql now, Thank you @user
1

if you already installed required systems for python 2.7. Next, You should run this command:

sudo apt-get install python2.7-mysqldb

1 Comment

Thank you, I tried it. After running the program it is showing as ImportError: No module named mysql.connector
0

Problem: When trying to install and import mysql-connector-python, Python kept throwing an ImportError even after pip install mysql-connector-python.

Cause: The package was installed, but it was installed into a different environment than the one my Python interpreter was using (I hadn’t activated my virtual environment).

# Activate your virtual environment first
source venv/bin/activate   # on Linux / macOS

# then install the package
pip install mysql-connector-python

import mysql.connector

After activating the environment and reinstalling, the import worked without errors.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.