Python 32-bit can't find MySQLdb module on OS X Lion - python

I've been tearing my hair out and trying the solutions to getting Python and MySQL to play nicely with 64-bit architecture, and the solution seems to have all components installed/run as 32-bit.
My issue is that for some reason, running Python in 32-bit mode via
$ arch -i386 /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
and then
import MySQLdb
gives me
import MySQLdb
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named MySQLdb
However, when I run python in 64-bit mode and trying 'import MySQLdb' I get the dreaded:
import MySQLdb
Traceback (most recent call last):
File "", line 1, in
File "build/bdist.macosx-10.6-intel/egg/MySQLdb/init.py", line 19, in
File "build/bdist.macosx-10.6-intel/egg/_mysql.py", line 7, in
File "build/bdist.macosx-10.6-intel/egg/_mysql.py", line 6, in bootstrap
ImportError: dlopen(/Users/me/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.6-intel.egg-tmp/_mysql.so, 2): no suitable image found. Did find:
/Users/me/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.6-intel.egg-tmp/_mysql.so: mach-o, but wrong architecture
So my question is, why can't Python find the module in 32-bit mode? the "wrong architecture" error leads me to believe that MySQL-python is installed as 32-bit, so I don't think it's that 32-bit Python can't "see" the module. I have both the python and the .python-eggs path on my $PATH in .bash_profile, so what am I missing here?

Not exactly an answer, but have you tried just to pip install MySQL-python? If you have some mysql_config in your path, it should compile just fine.
– I am using a Python 2.7.2 via homebrew, a MAMP 2.0 installation, running on 10.6. with a 64bit kernel.

Related

Problem importing a specific library with python 2.7.10

I am trying to install the following package in my MacOS High Sierra 10.13.6:
https://github.com/Michalychforever/CLASS-PT
When i run the make file everything looks to work fine. It not only generate an executable, which i can run by terminal using the ./ command, but also a python wrapper. The problem is related only with the former.
When i try to import the library i get the following message:
import classy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dlopen(/Users/thiagomergulhao/Library/Python/2.7/lib/python/site-packages/classy.so, 2): Symbol not found: _zdotu_
Referenced from: /Users/thiagomergulhao/Library/Python/2.7/lib/python/site-packages/classy.so
Expected in: flat namespace
in /Users/thiagomergulhao/Library/Python/2.7/lib/python/site-packages/classy.so
I am using the built-in python version (i.e 2.7.10). I already installed the Xcode 10.1 together with command line commands. My .bash_profile is:
export PATH="/Users/thiagomergulhao/Library/Python/2.7/bin:$PATH"
export PATH=/usr/local/bin:/usr/local/sbin:$PATH
Does anyone have any ideia what is causing this problem?

Python3 and GTK3 on Windows

I am currently trying to use GTK3 and Python3 for GUI development.
Everything is working fine while doing this on my Ubuntu device, but as I want to be able to have Windows executables later, I need to set these tools up on Windows 7.
I have Python 3.4.4 (64 Bit) installed on my system and tried solutions from other posts on Stackoverflow to be able to use GTK with it, but I was not able to get it to work.
When trying to import Gtk (import gi and from gi.repository import Gtk) on the Python shell, the following error occurs:
Traceback (most recent call last):
File "<frozen importlib._bootstrap>", line 2158, in _find_spec
AttributeError: 'DynamicImporter' object has no attribute 'find_spec'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python34\lib\site-packages\gi\importer.py", line 100, in find_module
'introspection typelib not found' % namespace)
ImportError: cannot import name Gtk, introspection typelib not found
What I have installed at the moment:
PyGi 3.18.2 AIO for Python 3.4 64-bit
GTK3-Runtime Win64 (bin directory created during installation is included into PATH)
Which is the best way to get a working set of Python3 and GTK3 on Windows? (As far as I have seen it is not possible to create Windows executables using Ubuntu.)
You need only to install Python 3.4 and the PyGObject project on sourceforge (the one you mentioned in your post).
This setup must work on Windows, because it works for me.
Maybe you missed to check the Gtk3 libraries during installation of PyGObject (this is a frequent error).
You don't need msys2 at all to use PyGObject in Python.

wxPython import error with Windows install

I have installed Python 3.4 and wxPython Phoenix on Windows 10. I go into Eclipse and add wxPython to the external libs in my project, but when I try to import it, I get this error:
Traceback (most recent call last):
File "C:\Users\linus\workspace\MiCS 1.2\main.py", line 1, in <module>
import wx
File "C:\Python34\Lib\site-packages\wx\__init__.py", line 17, in <module>
from wx.core import *
File "C:\Python34\Lib\site-packages\wx\core.py", line 6, in <module>
from ._core import *
ImportError: DLL load failed: The specified module could not be found.
I did some searching and tinkering and still can't figure out what's causing it. It shouldn't be the msvcp or msvcr DLLs as I have Office running just fine (or is that an incorrect assumption?) Any help is appreciated. Thanks.
How did you install wxpython?
As of now, the top page of the official site has wxpython 3.0 only for python27. So, I suspect you might not have installed it properly.
If you have your python34 at C:/Python34 then, cd to C:/Python34/Scripts first so that we make sure to use the pip for this python.
According to this post (https://groups.google.com/forum/#!topic/wxpython-dev/LmGIrQyh7jc), try
pip install -U --pre -f http://wxpython.org/Phoenix/snapshot-builds/ wxPython_Phoenix
This should find the corresponding whl file for your python version and CPU architecture.
Or, you could manually download whl file at http://wxpython.org/Phoenix/snapshot-builds/
If you have 32 bit Python34, then look for ******-cp34-none-win32.whl
and simply do:
pip install path/to/the/whl/that/you/just/downloaded/wxPython_Phoenix-3.0.3.dev1839+4ecd949-cp34-none-win32.whl
After this, if you can import wx in the normal cmd then the problem should be coming from eclipse.

python import from gdbinit doesn't work

I have installed python-opencv and I can run import cv2 and check version without problems from a python shell.
When trying to source this python file in gdb to provide a new gdb command I always get:
(gdb) source /opt/src/matrix-viewer/misc/matrix-viewer-gdb.py
Traceback (most recent call last):
File "/opt/src/matrix-viewer/misc/matrix-viewer-gdb.py", line 17, in <module>
import cv2.cv as cv
ImportError: No module named 'cv2'
My PC has got the sole python instance from Ubuntu distribution, why from gdb I'm getting an import problem regarding this just installed package that I'm able to load from a python shell.
EDIT
This is a python 2 package, and gdb loads python 3... Seems unsolvable.

Python 2.6.7 not initialing in windows

I am trying to get Python to run to use with Blender. I have 64 bit Vista SP2. 2.6.7 Python. When I start python the command prompt tells me this
'imprt site' failed; use -v for traceback
Traceback <most recent call last>:
File "c:\Python26\Scripts\pypm-script.py", line 5, in <module>
Import Error: No module named pkg_resources
So, I opened pypm-script.py
#!python2.6.exe
# EASY-INSTALL-ENTRY-SCRIPT: 'pypm==1.3.4','console_scripts','pypm'
__requires__ = 'pypm==1.3.4'
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.exit(
load_entry_point('pypm==1.3.4', 'console_scripts', 'pypm')()
)
This is very frustrating, because have no idea how to read code or how to use Python! I hope this is easily fixable.
The file pypm-script.py (and pkg_resources) come from ActivePython. You probably must have installed a different Python on top of ActivePython. I can think of two ways to fix this problem:
Uninstall Python, remove C:\Python26 and install ActivePython 2.6 (or 2.7), or
Remove C:\Python26\Scripts\pypm* and C:\Python26\Lib\site-packages\pypm*

Categories

Resources