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.
Related
The default Python version for MSYS2 seems to be 3.8. I need to use 3.7 at the moment because I have to use PyInstaller and it is not currently compatible with 3.8 in MSYS2. I can download the earlier version of Python from http://repo.msys2.org/ and install it using pacman. With a fresh install of MSYS2 I run the following commands:
pacman -S glib2-devel
pacman -U python-3.7.4-1-x86_64.pkg.tar.xz
pacman -S python-pip
pacman -S python-setuptools
If I try to run a python script I am met with an error:
File "setup.py", line 15, in <module>
from setuptools import setup
ModuleNotFoundError: No module named 'setuptools'
This is due to the fact that everything installed after Python is actually installing in the default Python 3.8 location rather than 3.7:
C:\msys64\usr\lib\python3.8\site-packages
If I copy and paste the contents of site-packages into Python 3.7 and then try running a script I get the error:
File "setup.py", line 15, in <module>
from setuptools import setup
File "/usr/lib/python3.7/site-packages/setuptools/__init__.py", line 19, in <module>
from setuptools.dist import Distribution
File "/usr/lib/python3.7/site-packages/setuptools/dist.py", line 34, in <module>
from setuptools import windows_support
File "/usr/lib/python3.7/site-packages/setuptools/windows_support.py", line 2, in <module>
import ctypes
File "/usr/lib/python3.7/ctypes/__init__.py", line 7, in <module>
from _ctypes import Union, Structure, Array
ImportError: No such file or directory
Which is supposed to be resolved via libffi, which was installed prior to Python, but likely does not go to a location that 3.7 can recognize?
Is there a way to set a specific version of Python as the default in MSYS2? Perhaps a path that can be set in the .bashrc file? I tried to set PYTHONPATH in there to Python 3.7 but it didn't make a difference as to where the packages ended up being installed to.
Go to the following URL...
https://repo.msys2.org/msys/x86_64/
Look for the version of the package you need and download it. Use
pacman -U pkgname
To install it...
The reason I know this is because gcc11 on MSYS is non-functional... it produces programs which crash and say
"During startup your program exited with code..." mentioned here:
During startup program exited with code 0xc0000139
The only workaround is to downgrade to the previous compiler which does work or use clang, which was not an option for me.
Trying to use an old version of Python is probably possible, but I think it will be very difficult. You would need to make sure all the other installed packages are compatible.
I am using PyInstaller with Python 3.8 in MSYS2 without issues. I would recommend trying to work through any issues with that, instead of trying to use older versions of packages.
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.
Not able to install any packages
I've tried VLC package from https://wiki.videolan.org/python_bindings
and got a traceback.
Now I am trying pygame module and this is what i get
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
import pygame
File "C:\Users\Vineeth\AppData\Local\Programs\Python\Python36-32\lib\pygame\__init__.py", line 133, in <module>
from pygame.base import *
ImportError: DLL load failed: The specified module could not be found.
Please help i am pretty new to python
There are some release binaries for Python3.x, 64bit Windows at http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame
I suggest you download it from that site and install it. It works for me. If you are using Windows ,it is a good way to install some packages,like lxml matplotlib.
Also you check out this question.
Hope this helps.
I tried to execute your statements and the imports worked fine for me. I have a 64bit Windows OS. And my python version Python 3.5.2 - 64bit.
Check if you have other Python versions, if you have removed them, make sure you did that right.
Ultimately I would just suggest you to do pip install pygame. The version compatibility will be handled by pip itself.
I have installed Kivy on my Mac. OS X comes installed with Python 2.7. I wanted to use the enum feature of Python 3, so I installed Python 3.4. After much searching and oulling of hair, I was pointed to this line
exec $(python -c "import os, sys; print os.path.normpath(sys.prefix)")/bin/python2.7 "$#"
in the file /Applications/Kivy.app/Contents/Resources/script. I changed it to:
exec /Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4 "$#"
in the hope of forcing Kivy to use Python 3.4.
I now get this error:
Traceback (most recent call last):
File "main.py", line 1, in <module>
from kivy.app import App
File "/Applications/Kivy.app/Contents/Resources/kivy/kivy/app.py", line 321, in <module>
from kivy.base import runTouchApp, stopTouchApp
File "/Applications/Kivy.app/Contents/Resources/kivy/kivy/base.py", line 29, in <module>
from kivy.event import EventDispatcher
File "/Applications/Kivy.app/Contents/Resources/kivy/kivy/event.py", line 8, in <module>
import kivy._event
ImportError: dlopen(/Applications/Kivy.app/Contents/Resources/kivy/kivy/_event.so, 2): Symbol not found: _PyString_Type
Referenced from: /Applications/Kivy.app/Contents/Resources/kivy/kivy/_event.so
Expected in: flat namespace
in /Applications/Kivy.app/Contents/Resources/kivy/kivy/_event.so
Can anyone help in fixing this error? Or is there a better way to get Kivy to use Python 3.4?
I have installed Kivy 1.8.0.
I am running the app from the terminal, e.g.
kivy main.py
This line:
dlopen(/Applications/Kivy.app/Contents/Resources/kivy/kivy/_event.so, 2)
Is trying to open a shared object, which would have been compiled for the explicit version of Python that your install of Kivy was intended for.
Any Python package that includes precompiled dependencies will only work for the version of Python they were compiled against.
Kivy has not yet been tested with Python 3.4. It runs fine with Python 3.3.
I've gotten kivy working on OSX El Capitan with Python 3.5. Here's how I did it.
You will need to brew install the dependencies, then modify setup.py to use the brew installed dependencies. The default setup.py will look to your frameworks directory, but that's not where brew puts the new files!
I was able to install kivy for python 3.5. I didn't have to do anything extra, just regular install kivy and it is working.
I am, like many others, trying to get MySQLdb for Python to run on Mac Snow Leopard (10.6.x) and I've been able to install the 64-bit MySQL DMG as recommended by various blogs/forum posts, and I've been able to install the setuptools and MySQLDB itself by using the
ARCHFLAGS='-arch 86_64' python2.7 setup.py clean
ARCHFLAGS='-arch 86_64' python2.7 setup.py build
sudo ARCHFLAGS='-arch 86_64' python2.7 setup.py install
As you can see from the above I have upgraded to Python 2.7 and everything seems fine; except when I try to import MySQLdb into python shell.
>>> import MySQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build/bdist.macosx-10.6-universal/egg/MySQLdb/__init__.py", line 19, in <module>
File "build/bdist.macosx-10.6-universal/egg/_mysql.py", line 7, in <module>
File "build/bdist.macosx-10.6-universal/egg/_mysql.py", line 6, in __bootstrap__
ImportError: dlopen(/Users/ad/.python-eggs/MySQL_python-1.2.3c1-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so, 2): Library not loaded: /usr/local/mysql/lib/libmysqlclient.16.dylib
Referenced from: /Users/ad/.python-eggs/MySQL_python-1.2.3c1-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so
Reason: Incompatible library version: _mysql.so requires version 17.0.0 or later, but libmysqlclient.16.dylib provides version 16.0.0
I did a search and found libmysqlclient.16.dylib but not libmysqlclient.17.dylib
What is causing this problem, how do I resolve it, and even though I did a search for libmysqlclient.17.dylib there seems to be nothing about it; does it exist?
Thanks
You built the module against MySQL 5.5.x, but only the client libraries for 5.1.x are available on the system. Either install updated libraries, or build against an older version.
Definitely make sure that Python and MySQL are for the same architecture. You have to consistently use either 32bit or 64bit versions for both.
Also make sure that MySQLdb can find the MySQL libraries and includes, but from your error message it seems like this is the case.