I use this tutorial text as an example, there are others:
#!/usr/bin/python
import MySQLdb
If it produces the following result, then it means MySQLdb module is not installed −
Traceback (most recent call last):
File "test.py", line 3, in <module>
import MySQLdb
ImportError: No module named MySQLdb
To install MySQLdb module, use the following command −
For Ubuntu, use the following command -
$ sudo apt-get install python-pip python-dev libmysqlclient-dev
I have gone trough these steps, more or less as described above.
Problem is that the subdirectory "python" does not exist under /usr/bin/
in my file system. I run Linux Mint 18.3. Python 2.7 seems to be the native version installed in Mint (used for several purposes), but I have also installed Python 3.6.4 and wish to use this for development purposes.
Does anyone know in which directory I could expect to find MySQLdb?
Since #!/usr/bin/python is non existent I wonder - has MySQLdb been properly installed? If it has, I have not after several efforts succeded in locating it.
Related
I created .exe file using pyinstaller 3.3.1 and I got this message
Traceback (most recent call last):
File "install.py", line 14, in <module>
ImportError: No module named configobj
[8468] Failed to execute script install
I'm working with python 2.7 using conda environment. Lately I had updated pyinstaller to version 3.3.1 so this happened to me while I'm checking that the update is safe.
I have also created another .exe file from different script that uses also this import and its went well, so any help will be welcome.
I got this error from certbot on Ubuntu 20.04 (focal). On this version of Ubuntu, python 2 seems to be mostly deprecated and many things don't work when using it. Everything needs to be configured to use python3.
When I ran certbot, it was still using python 2.
File "/usr/local/lib/python2.7/dist-packages/certbot/main.py", line 9, in <module>
import configobj
ImportError: No module named configobj
Python 2 pip is no longer available from apt on this version of Ubuntu, so I was not able to install the proper libraries for python 2 using pip.
The version of certbot in apt is supposed to be for python3. (python3-certbot). The executable for certbot gets installed at /usr/bin/certbot.
After further investigating, I found that I had an older python 2 version of certbot hanging around at /usr/local/bin/certbot. Once I removed that (sudo rm /usr/local/bin/certbot), the python3 version of certbot runs just fine and is able to find all its libraries.
You need to install configobj via pip apt install python-pip
I am running Enthought Canopy, python version 2.7.3, and am having difficulties using the module MySQLdb. I installed MySQL_Python 1.2.3 from the Canopy Package Manager, but when I run my code I get
File "pyfits_test.py", line 2, in <module>
import MySQLdb as mdb
File "/home/cmessick/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/MySQLdb/__init__.py", line 19, in <module>
import _mysql
ImportError: libssl.so.6: cannot open shared object file: No such file or directory
Line 2 of my code simply says
import MySQLdb as mdb
I also tried
from MySQL_python import MySQLdb as mdb
and got
Traceback (most recent call last):
File "pyfits_test.py", line 2, in <module>
from MySQL_python import MySQLdb as mdb
ImportError: No module named MySQL_python
Does anybody have any suggestions to make Enthought Canopy work with MySQLdb?
Edit: Not sure it matters, but I'm running Ubuntu 12.04.
Second Edit: I figured out how to add to the module search path, so at the beginning of my code before anything else I now have:
import sys
sys.path.append('/usr/lib/python2.7/dist-packages/')
Once I do this, it works. Does anybody have a more permanent solution that I won't have to implement every time?
This is an old question now, but I just ran into the same problem with EPD 7.3-2 64-bit (not Canopy) on Ubuntu 13.10. The following approach fixed the issue for me:
cd /path/to/epd/lib
sudo ln -s libcrypto.so libcrypto.so.6
sudo ln -s libssl.so libssl.so.6
After this change, you should be able to import MySQLdb.
In your "fix," it appears you are adding the system python dist-packages directory to your EPD python search path; in general, you probably don't want to do this. Use enpkg to manage your EPD installation, and don't make your EPD python installation dependent upon the configuration of your system python.
Here is a post about installing a module in python3. When I use brew install python, then it installs it for 2.7.
When I use the method suggested by dan, which aimed to install it directly in python3 (who i really thank), but which didn't work :
# Figure out the path to python3
PY3DIR=`dirname $(which python3)`
# And /then/ install with brew. That will have it use python3 to get its path
PATH=$PY3DIR:$PATH brew install mapnik
The installation was successful but in python2. so I get:
For non-homebrew Python, you need to amend your PYTHONPATH like so: export PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH
so i finally add the path manually in python3 :
import sys
sys.path.append('/usr/local/lib/python2.7/site-packages')
I get this error :
Traceback (most recent call last): File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/mapnik/__init__.py", line 69, in <module>
from _mapnik import * ImportError: dlopen(./_mapnik.so, 2): Symbol not found: _PyClass_Type Referenced from: ./_mapnik.so
Expected in: flat namespace in ./_mapnik.so
Please help, I have spent so many hours on this ...
Thanks!!!
The Mapnik python bindings depend on boost_python. And both need to use the same python. The problem is likely that homebrew is providing a bottle of boost which includes boost python built against python 2.7 and not python 3.x.
I need to install Python 2.7 on a machine, from source, alongside the existing version on the machine (2.4). I have compiled and installed Python successfully, but when I try to run a script calling the MySQLDB module, it throws the following error:
[root#the-node1 bin]# interactive_recording_archive.py
Traceback (most recent call last):
File "/usr/local/bin/interactive_recording_archive.py", line 8, in <module>
import MySQLdb as mdb
ImportError: No module named MySQLdb
I have tried installing MySQLDB using the easy-install script but this fails to find any module by that name. I have MySQL installed and working on the machine.
What am I doing wrong?
The package is called MySQL-python:
easy_install MySQL-python
Do check the installation requirements; you have python and setuptools, but you need the mysql-devel package too.
I am new in python meep. I try to use python-meep on Ubuntu 10.04 64 bit (virtual machine).
I install all the necessary things like PCRE swig and python meep, but when I try to run the samples it gives me the same error as in the beginning:
~/Desktop/Python/python-meep/samples/bent_waveguide$ python python_meep_bent_wg.py
Traceback (most recent call last):
File "python_meep_bent_wg.py", line 21, in <module>
from meep import * # make it 'meep_mpi' for MPI-meep and 'meep' for non-MPI meep
File "/usr/local/lib/python2.6/dist-packages/meep.py", line 4693, in <module>
import scipy.weave
ImportError: No module named scipy.weave
(about scipy I have a problem to install it - I get the message:
Error: Dependency is not satisfiable: python (<< 2.6)
... so I install it with dpkg -i, and then made some updates but in the end I have some kind of broken packages)
Right now I am really stuck and have no idea what to do. Maybe somebody has an idea how to fix it or install it correctly overcoming all these problems.
Try to use the python-setuptools, so you install the stuff with pip or easy_install.