I have followed the steps in the website below, and installed everyhting for MySQLdb.I am using Xampp for the database and I have linked the mysql_config to the xampp mysqlconfig.
http://www.tutorialspoint.com/python/python_database_access.htm
However, after everything was installed and when I try to import it says:
Python 2.7.5 (default, Mar 9 2014, 22:15:05)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.9-intel.egg/MySQLdb/__init__.py", line 19, in <module>
import _mysql
ImportError: dlopen(/Library/Python/2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.9-intel.egg/_mysql.so, 2): Library not loaded: libmysqlclient.18.dylib
Referenced from: /Library/Python/2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.9-intel.egg/_mysql.so
Reason: image not found
Thanks ahead of time for all your help!
What solved my problem is:
Installed homebrew from this website:http://brew.sh
Installed mysql using brew:
brew install mysql
Followed this website to build and install python MySQLdb:http://www.tutorialspoint.com/python/python_database_access.htm
After all of that everything is perfectly working.So if anyone is having trouble with MySQLdb on a Mac, then just follow those instructions. I hope this helps.
Related
I recently installed openalpr on my mac using brew install openalpr with success. I would like to use the openalpr library with python 2.7 but I am having difficulty binding the two and could use some help.
I currently get the following in my projects file location:
Python 2.7.11 (default, Jan 22 2016, 08:29:18)
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from openalpr import Alpr
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named openalpr
>>>
When I move to /usr/local/Cellar/openalpr/2.3.0/lib/python2.7/dist-packages/openalpr
The import works. How can I bind this library? Thanks
EDIT: I think I've seen that running the setup.py for openalpr is how you bind but I have no idea where to find it in my file system.
I had to do the following command:
echo /usr/local/opt/openalpr/lib/python2.7/dist-packages/ >> /usr/local/lib/python2.7/site-packages/openalpr.pth
I'm trying to work with psycopg2 natively on Mac. It installs fine, with no errors at least, but when i import it get an error message.
I've seen dozens of threads with similar issues and solutions that vary massively and just seem excessive for such a common module.
can anyone help?
Last login: Wed Oct 12 15:47:24 on console
Gurmokhs-MBP:~ Gurmokh$ pip install psycopg2
Requirement already satisfied (use --upgrade to upgrade): psycopg2 in /Library/Python/2.7/site-packages
Gurmokhs-MBP:~ Gurmokh$ python
Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 12:54:16)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import psycopg2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site- packages/psycopg2-2.6.2-py2.7-macosx-10.6-intel.egg/psycopg2/__init__.py", line 50, in <module>
from psycopg2._psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site -packages/psycopg2-2.6.2-py2.7-macosx-10.6- intel.egg/psycopg2/_psycopg.so, 2): Library not loaded: libssl.1.0.0.dylib
Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site- packages/psycopg2-2.6.2-py2.7-macosx-10.6-intel.egg/psycopg2/_psycopg.so
Reason: image not found
>>> ^D
Gurmokhs-MBP:~ Gurmokh$
I can see some copies floating round from different applications.
I'm assuming i could copy one of these. The above message tells me what is referencing this file, but they do not tell me where they expect to find it. If i knew where it should go i would try this.
bash-3.2# find . -name "libssl.1.0.0.dylib"
./Library/Application Support/Fitbit Connect/libssl.1.0.0.dylib
./Library/PostgreSQL/9.5/lib/libssl.1.0.0.dylib
./Library/PostgreSQL/9.5/pgAdmin3.app/Contents/Frameworks/libssl.1.0.0.dylib
./Users/Gurmokh/.Trash/Navicat for PostgreSQL.app/Contents/Frameworks/libssl.1.0.0.dylib
Thanks guys.
#maxymoo I went with your suggestion. I have installed anaconda2. The install updated my path to include /anaconda/bin.
Then using the navigator I installed pyscopg2. Now I am able to use this in the shebang and my scripts execute fine and i'm able to import this module.
Gurmokhs-MBP:rest Gurmokh$ python
Python 2.7.12 |Anaconda 4.2.0 (x86_64)| (default, Jul 2 2016, 17:43:17)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import psycopg2
if psycopg2.connect("dbname='postgres' user='postgres' host='localhost'"):
... print "connection made"
...
connection made
>>>
I'm installing cassandra-driver with pip on OSX 10.11.
Straight out of pip, cassandra-driver gives this error:
traceback (most recent call last): File "syncS3ToCassandra.py", line 19, in <module>
from cassandra.cluster import Cluster File "cassandra/cluster.py", line 48, in init cassandra.cluster (cassandra/cluster.c:74747)
File "cassandra/connection.py", line 38, in init cassandra.connection (cassandra/connection.c:28007)
ImportError: No module named queue
I haven't tried building cassandra-driver from source but pip is the recommended method. Here's my code:
from cassandra.cluster import Cluster
from cassandra.policies import DCAwareRoundRobinPolicy
cluster = Cluster()
session = cluster.connect('foo')
I also meet this issue on my mbp. And there are some other problems that I can't uninstall six. I use easy_install to update version from 1.4.1 to 1.10.0 to fix it.
$sudo easy_install -U six
Hope it can help you.
From the source code, you need the package six to be installed and it should have a subpackage moves which contains a module queue.py:
38 from six.moves.queue import Queue, Empty
Can you try to reinstall six?
pip uninstall six
pip install six
Since cassandra-driver (version 3.4.1) is only available as .tar.gz package, you have to recompile it from the sources. This is what pip do.
I successfully install it on OSX 10.11.5 (it took at least one minute to compile).
I try this:
$ python
Python 2.7.10 (default, Oct 23 2015, 19:19:21)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from cassandra.cluster import Cluster
>>> from cassandra.policies import DCAwareRoundRobinPolicy
>>> cluster = Cluster()
>>> session = cluster.connect('foo')
Traceback (most recent call last):
...
cassandra.cluster.NoHostAvailable: ('Unable to connect to any servers', {'127.0.0.1': error(61, "Tried connecting to [('127.0.0.1', 9042)]. Last error: Connection refused")})
The last error is normal because I don't have the server.
EDIT: Installation in Python 3.5
I successfully installed and tested (as much as I can) this driver in Python 3.5.1 on OSX 10.11.5
$ python
Python 3.5.1 (v3.5.1:37a07cee5969, Dec 5 2015, 21:12:44)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from cassandra.cluster import Cluster
>>> from cassandra.policies import DCAwareRoundRobinPolicy
>>> cluster = Cluster()
>>> session = cluster.connect('foo')
Traceback (most recent call last):
...
cassandra.cluster.NoHostAvailable: ('Unable to connect to any servers'[..])
I have created a virtualenv using base prefix '/Library/Frameworks/Python.framework/Versions/3.5'.
I solved this issue by updating my ~/.profile with:
export PATH=/usr/local/bin:/usr/local/sbin:$PATH
and installing python-2.7.11
$ brew install python
Then restarting my shell.
When I try to import vtk, it doesn't work.
I tried this method (build the vtk with cmake and update environment variables - except the "Post installation tasks"), but I still have :
$python
Python 2.7.6 (default, Sep 9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import vtk
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named vtk
I tried before that
sudo brew install python-vtk
but it returns :
Error: No available formula with the name "python-vtk"
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching taps...
Error: No formulae found in taps.
How can I import vtk in my Python code on my Mac computer without problem ?
Use the darwin dmg file here;
http://www.vtk.org/download/#latestcand
I am trying to run python in an Apache WS in a linux RHEL x86_64.
After Install and configure Python2.5 and Apache, I install Oracle Instant Client (basic and sdk) in a by an .rpm file withou any problem.
oracle-instantclient-basic-10.2.0.4-1.x86_64.rpm
oracle-instantclient-devel-10.2.0.4-1.x86_64.rpm
I set the envoirment variables
export ORACLE_HOME=/appl/paths/instantclient_10_2
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export PATH=$ORACLE_HOME/bin:$PATH
Then install cx_Oracle by an .rpm file too and again withou any problem.
cx_Oracle-5.0.3-10g-unicode-py25-1.x86_64.rpm
When I try to import cx_Oracle in python I got the message
Python 2.5.2 (r252:60911, Jul 1 2010, 17:47:36)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cx_Oracle
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: /appl/paths/python2.5/site-packages/cx_Oracle.so: undefined symbol: OCIDBShutdown
I google for answers without success. Any tip?
The problem was in the ORACLE_HOME, there was a misspelling on it
I solved the same problem by installing an older version of cx_Oracle (4.3.1 instead of 5.1.2). Just for future reference.