MySQLdb module is not installed on my python - python-2.7

I am trying to install the mysqldb module in my python2.7 ubuntu. I am using the following ways to install
$ tar -xvf MySQL-python-1.2.2.tar
$ cd MySQL-python-1.2.2
$ sudo python setup.py build
$ sudo python setup.py install
then i am going to import the module. It shows the following error.
import MySQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named MySQLdb
I have also tried to install by using apt-get and pip. there is no way it shows the same above import error. Could you please help me? thanks in advance.

Related

H5PY installed, but does not import

I am trying to import H5PY in my Python code, but the module cannot be found. I am using Ubuntu 16.04 and Python 2.7.
I have tried reinstalling h5py both with conda and with pip and individually and the following
sudo pip install cython
sudo apt-get install libhdf5-dev
sudo pip install h5py
but it still does not work.
Installing h5py tells me that it is already installed in /anaconda2/lib/python2.7/site-packages.
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/snap/pycharm-community/128/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
ImportError: No module named h5py
Has anyone fixed this problem?
I found my solution!
I added found out the path where h5py is installed and added it to the path where python looks for the modules with
import sys
sys.path.append("mypath")
Hope this also helps others
For me the following worked:
sudo apt-get update
sudo apt-get install python3-h5py
Ref: https://www.devmanuals.net/install/ubuntu/ubuntu-16-04-LTS-Xenial-Xerus/how-to-install-python3-h5py.html

Import Error: No Module named ldap, issues with python-ldap module installation on mac os Serira, python 2.7

Running a simple standalone python script on mac os Sierra. I am getting the following error:
Traceback (most recent call last):
File "user_exists.py", line 4, in <module>
import ldap
ImportError: No module named ldap
I went and tried installing using pip the module, I get the following output:
$sudo -H pip install
Requirement already satisfied: python-ldap in /usr/local /bin/python_ldap-2.4.28-py2.7-macosx-10.12-intel.egg
Requirement already satisfied: setuptools in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from python-ldap)
I tried testing:
$ python -c "import ldap"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named ldap
Please suggest whats the best approach to solve this issue?

'ModuleNotFoundError: No module named 'MySQLdb' In Django

creating my first module in django,
I am using mac Tried steps:
1.installed python 3.6.+ version,
2.cloned git project
3.setup local env,
to create a module,
trying with command
env=dev python3 manage.py startapp supriya_module_inflow;
getting error in console :
Environment Selected :dev
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 24, in <module>
import MySQLdb as Database
ModuleNotFoundError: No module named 'MySQLdb'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 35, in <module>
execute_from_command_line(sys.argv)......
...
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named 'MySQLdb'
MySQLdb does not support Python 3. You'll want to pick one of the other MySQL drivers.
At the time of writing, the latest release of MySQLdb (1.2.5) doesn’t support Python 3. In order to use MySQLdb under Python 3, you’ll have to install mysqlclient instead.
Here is How to install mysqlclient in Python using pip so as to be able to import MySQLdb in Django 3.1 when running Python 3.8.5..
The error message indicates that there is no module named MySQLdb. It means, Python needs a module to interface with MySQL database and that modules does not seems to be present in the system. All you need to do is, just install MySQL-Python module and the script should work without any problem.
Using Python Pip
pip install MySQL-python
Collecting MySQL-python
Installing collected packages: MySQL-python
Running setup.py install for MySQL-python
Successfully installed MySQL-python-1.2.5
On Ubuntu based systems
# apt-get install python-mysqldb
On RHEL/CentOS based systems:
# yum install MySQL-python
Using easy_install
# easy_install mysql-python
If you are on a virtual environment then
pip install MySQL-python
You can also check this related issue.
** Building wheel for MySQL-python (setup.py) ... error
ERROR: Command errored out with exit status 1:**
can't able to install MySQL-python and getting the above error .

ImportError: matplotlib requires dateutil- python

I get this error when i try to import matplotlib. I have installed matplotlib.
Traceback (most recent call last):
File "<pyshell#23>", line 1, in <module>
import matplotlib
File "C:\Python27\lib\site-packages\matplotlib\__init__.py", line 110, in <module>
raise ImportError("matplotlib requires dateutil")
ImportError: matplotlib requires dateutil
how do I solve this problem?
matplotlib depends on dateutil
On Linux you can install it using
pip install python-dateutil
You can reinstall them forcefully using
pip install python-dateutil --force-reinstall --upgrade
To install pip on windows get the script get-pip.py from here. Then on cmd run
python get-pip.py

Error with virtualenv after having installed python 2.7

I've just installed python 2.7 from source for my Debian Squeeze. But now, when I use virtualenv, for this specific python version, I have this error:
~/ENV$ virtualenv -p /usr/local/bin/python2.7 --no-site-packages --distribute script_prod
Traceback (most recent call last):
File "/usr/bin/virtualenv", line 2, in <module>
import virtualenv
ImportError: No module named virtualenv
How can I fix it?
I've found out that I need to install virtualenv with python2.7 in order to make it works!