ModuleNotFoundError: No module named 'MySQLdb' python macOS high sierra - python

Everytime I execute my python code, it gives me the above ModuleNotFound error when I execute with python3. With python, it gives me an ImportError.
I have updated setuptools using pip install --upgrade setuptools.
I have also tried multiple commands such as: pip install mysqlclient, pip install MySQL-python, pip install pymysql.
I have tried these commands with pip3 as well (Not sure if it makes a difference).
Everytime I try these commands, it gives me the following error:
Complete output from command python setup.py egg_info:
/bin/sh: mysql_config: command not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/0y/xsr1t8rs36l0vlq3_f2q42g40000gn/T/pip-install-soxlcjei/mysqlclient/setup.py", line 16, in <module>
metadata, options = get_config()
File "/private/var/folders/0y/xsr1t8rs36l0vlq3_f2q42g40000gn/T/pip-install-soxlcjei/mysqlclient/setup_posix.py", line 51, in get_config
libs = mysql_config("libs")
File "/private/var/folders/0y/xsr1t8rs36l0vlq3_f2q42g40000gn/T/pip-install-soxlcjei/mysqlclient/setup_posix.py", line 29, in mysql_config
raise EnvironmentError("%s not found" % (_mysql_config_path,))
OSError: mysql_config not found
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/0y/xsr1t8rs36l0vlq3_f2q42g40000gn/T/pip-install-soxlcjei/mysqlclient
How do I fix this? I am using a macOS High Sierra. I have gone through solutions for similar problems on ubuntu/debian systems and have to tried to apply it here. None of that works on a mac. Also, i already have mysql installed and it works perfectly. It is constantly running on my system.

you should download a tar named as Mysql-python-1.2.4b4.tar.gz, and unzip it, cd to the dir and update the file site.cfg: # mysql_config = /usr/local/mysql/bin/mysql_config to mysql_config = /usr/local/mysql/bin/mysql_config
and then python setup.py install, after you installed the mysql-python,then you can not get the error.

Related

How to install pywhatkit?

i am having a problem regarding installing pywhatkit in python
version - pycharm 2016, python 3.3.0
Executed command:-
pip install --user pywhatkit
The command output is:-
Collecting pywhatkit
Using cached https://files.pythonhosted.org/packages/6b/f8/7f2763b08be029e5b199178c99b2017533e23c1d9e5e07229fd078e1a183/pywhatkit-5.4.1.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\user\AppData\Local\Temp\pycharm-packaging\pywhatkit\setup.py", line 12, in <module>
with open("requirements.txt", "r") as f:
FileNotFoundError: [Errno 2] No such file or directory: 'requirements.txt'
----------------------------------------
DEPRECATION: Python 3.3 supported has been deprecated and support for it will be dropped in the future. Please upgrade your Python.
Command "python setup.py egg_info" failed with error code 1 in C:\Users\user\AppData\Local\Temp\pycharm-packaging\pywhatkit\
I was trying to install it by:
pressing ctrl + alt +s
and then clicking on project interpreter
and then clicking on the '+' icon and installing it from there
Try running the line:
pip install pywhatkit
(At least that is the line I ran when I installed it.)
It looks like package has wrong path for requirements - maybe try to install lower version ?
Or if not try gihtub installation: https://github.com/Ankit404butfound/PyWhatKit/wiki

Error with pip and installing mysql-python

I cannot seem to understand why I am getting this issue whenever I am running the command pip install MySQL-python in Ubuntu. This is what I am getting.
pip install MySQL-python
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020.
Please upgrade your Python as Python 2.7 won't be maintained after that
date. A future version of pip will drop support for Python 2.7.
Collecting MySQL-python
Using cached https://files.pythonhosted.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip
Complete output from command python setup.py egg_info:
sh: 1: mysql_config: not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-dggKCf/MySQL-python/setup.py", line 17, in <module>
metadata, options = get_config()
File "setup_posix.py", line 43, in get_config
libs = mysql_config("libs_r")
File "setup_posix.py", line 25, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-dggKCf/MySQL-python/
Your version of python is close to the end, so you are invited to upgrade your python's version.
Mysql-python needs this old version of python and become deprecated.

Error when installing scapy

Ok so i'm trying to install scapy for python3, but ive been having some issues
when I enter this command:
pip install scapy
This is the output:
Collecting scapy
Using cached scapy-2.3.3.tgz
In the tar file C:\Users\MYNAME~1\AppData\Local\Temp\pip-oao3meyq-
unpack\scapy-2.3.3.tgz the member scapy-2.3.3/README
is invalid: unable to resolve link inside archive
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\MYNAME~1\AppData\Local\Temp\pip-build-
qjegdxw6\scapy\setup.py", line 36
os.chmod(fname, 0755)
^
SyntaxError: invalid token
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in
C:\Users\MYNAME~1\AppData\Local\Temp\pip-build-qjegdxw6\s
capy\
So then I searched around and I tried using this:
pip3 install scapy-python3
But it just says that pip3 isnt a command, so im not sure what to do
Instead of pip3 use pip
pip install scapy-python3
It worked for me. pip3 is usually used if you have both python2 and python3 installed on your machine. It is uesd to distinguish between different pips in your system.
The pip3.exe will be in python3x/scripts/.
Check if there is a pip3.exe is available in your scripts folder.
If the above solution doesn't work for you then try giving the full path of correct pip.exe.

How to install MySQL-python on Amazon Web Services EC2 instance?

I have a EC2 instance created on AWS and use PuTTY to connect to it.
I'm unable to install MySQL-python using python pip command as follows:
pip install MySQL-python(via root privileges)
Here is the console output of the error
Collecting MySQL-python
Using cached MySQL-python-1.2.5.zip
Complete output from command python setup.py egg_info:
sh: mysql_config: command not found
Traceback (most recent call last):
File "<string>", line 20, in <module>
File "/tmp/pip-build-JGbAEI/MySQL-python/setup.py", line 17, in <module>
metadata, options = get_config()
File "/tmp/pip-build-JGbAEI/MySQL-python/setup_posix.py", line 43, in get_config
libs = mysql_config("libs_r")
File "/tmp/pip-build-JGbAEI/MySQL-python/setup_posix.py", line 25, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-JGbAEI/MySQL-python
However I'm able to install other packages using pip
Please Guide.
mysql_config is available after installation of the following package on Amazon Linux:
sudo yum install -y mysql-devel
It looks like mysql_config is missing, so make sure mysql_config is really installed.
For example on Debian/Ubuntu you must install the package:
sudo apt-get install libmysqlclient-dev

Unable to do pip install mysql-python on virtualenv

I use macports and I have successfully install mysql5 using macports, and my python also managed by macports. Currently I am trying to do pip install mysql-python on my virtualenv but I am getting an error which says, mysql_config not found:
~/code]$pip install mysql-python
Downloading/unpacking mysql-python
Running setup.py egg_info for package mysql-python
sh: mysql_config: command not found
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "~/myVirtualEnv/build/mysql-python/setup.py", line 18, in <module>
metadata, options = get_config()
File "setup_posix.py", line 43, in get_config
libs = mysql_config("libs_r")
File "setup_posix.py", line 25, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found
Complete output from command python setup.py egg_info:
sh: mysql_config: command not found
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "~/myVirtualEnv/build/mysql-python/setup.py", line 18, in <module>
metadata, options = get_config()
File "setup_posix.py", line 43, in get_config
libs = mysql_config("libs_r")
File "setup_posix.py", line 25, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found
I read many google examples but more I read helped me to confuse myself further.
Looks like macport have had a issue but it has been closed for while.. http://trac.macports.org/ticket/6982
MacPort creates a symbolic link mysql_config5 in /opt/local/bin to /opt/local/lib/mysql5/bin/mysql_config. Create another link called mysql_config.
cd /opt/local/bin
sudo ln -s /opt/local/lib/mysql5/bin/mysql_config .
I seem to recall having to create a my.cnf too. By default Mac OSX uses all the defaults and doesn't create a my.cnf, create one /etc/my.cnf, it can be trivial.
Mine is just:
[mysqld]
bind-address = 0.0.0.0
port = 3306
mysql_config is an executable that it is in the libmysqlclient package so you need to install. On Deb systems you could install this using
sudo apt-get install libmysqlclient-dev
in RPM
RPM equivalent: sudo yum install mysql-devel
in mac maybe
Macports - port install mysql5 +server
Add /opt/local/lib/mysql5/bin/ to your command search path and then rerun the "pip install" command should solve the problem.
export PATH=/opt/local/lib/mysql55/bin/:$PATH
pip install mysql-python
I encountered the same issue, and solved it:
Install mysql. If you have installed it, ignore this step.
yum install mysql-devel
If you encountered error like Python.h: No such file or directory,
run yum -y install python-devel

Categories