I've recently installed django and psycop2. However python is refusing to use it below is the error. Can someone please help?
>>> 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/__init__.py", line 67, 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/_psycopg.so, 2): Symbol not found: _PQbackendPID
Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/psycopg2/_psycopg.so
Expected in: flat namespace
in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/psycopg2/_psycopg.so
macports is terrible for python/django development, everything seems to be out of data.
I have my team doing the following for postgres:
Download and install postgresql 9.0 but read the README before
installing !!!
Download psycopg2 source from http://initd.org/pub/software/psycopg/
Edit the setup.cfg to set pg_config to
/Library/PostgreSQL/9.0/bin/pg_config
Then install with
python setup.py install
I'd recommend using virtualenv as well, you want to stay away from the base Mac OS X python install as much as possible.
Related
I don't know much about python and I need help to install a python software.
I am using linux mint 12.8.
Since I have tried many things I think I have several versions of python installed (3.5 and 3.7 I think...).
When I run setup.py install I get:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 7, in <module>
import dbm.gnu as gdbm
File "/home/zach/10_Soft/anaconda3/lib/python3.7/dbm/gnu.py", line 3, in <module>
from _gdbm import *
ModuleNotFoundError: No module named '_gdbm'
I tried to install python3.5-gdbm (which appears to be up to date) and python3.7-gdbm (which is not found).
They both seem to be virtual packages of the same package python3-gdbm. I don't really know what to do with this information however...
Do you know what I should do?
I was able to solve this issue using this command:
sudo cp /usr/lib/python3.5/lib-dynload/_gdbm.cpython-35m-x86_64-linux-gnu.so /usr/lib/python3.7/lib-dynload/_gdbm.cpython-37m-x86_64-linux-gnu.so
I have some problems installing pyflann in python 3.7.3, after execute:
pip install pyflann
The installation is successfully accomplished, but when I import the library and a run a python program, I got this error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\Anaconda3\lib\site-packages\pyflann\__init__.py", line 27, in <module>
from index import *
ModuleNotFoundError: No module named 'index'
I'm using window 10. How can I fixed?
pyflann does not have support for python 3 yet, according to this GitHub issue. Your two options are:
Install the pyflann-py3 package:
pip install pyflann-py3
Or, you could take the advice from the issue and use 2to3:
sudo 2to3 -w D:\Anaconda3\lib\site-packages\pyflann
The pyflann package is not compatible with Python 3. It looks like
it is not actively maintained, the last commit was in February 2017:
https://github.com/primetang/pyflann/commits/master
There is an open issues documenting the problem:
https://github.com/primetang/pyflann/issues/1
There are a few open PRs trying to add Python 3 support that were never
merged:
https://github.com/primetang/pyflann/pulls
You might have better luck with one of the forks, but I can't vouch for them,
I've never used pyflann:
https://github.com/primetang/pyflann/network/members
I am using latest version macOS and homebrew, brew doctor find nothing wrong. and I just use brew install python, brew install python#2 to get latest version of python.
When I type python -c "import sqlite3", I get following error messages:
python2.7 -c "import sqlite3"
130 ↵ Traceback (most recent call last): File "", line 1, in
File
"/usr/local/Cellar/python#2/2.7.15_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sqlite3/init.py",
line 24, in
from dbapi2 import * File "/usr/local/Cellar/python#2/2.7.15_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sqlite3/dbapi2.py",
line 28, in
from _sqlite3 import * ImportError: dlopen(/usr/local/Cellar/python#2/2.7.15_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_sqlite3.so,
2): Symbol not found: _sqlite3_enable_load_extension Referenced
from:
/usr/local/Cellar/python#2/2.7.15_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_sqlite3.so
Expected in: /usr/lib/libsqlite3.dylib in
/usr/local/Cellar/python#2/2.7.15_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_sqlite3.so
python -c "import sqlite3"
1 ↵ Traceback (most recent call last): File "", line 1, in
File
"/usr/local/Cellar/python/3.7.2_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/sqlite3/init.py",
line 23, in
from sqlite3.dbapi2 import * File "/usr/local/Cellar/python/3.7.2_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/sqlite3/dbapi2.py",
line 27, in
from _sqlite3 import * ImportError: dlopen(/usr/local/Cellar/python/3.7.2_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload/_sqlite3.cpython-37m-darwin.so,
2): Symbol not found: _sqlite3_enable_load_extension Referenced
from:
/usr/local/Cellar/python/3.7.2_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload/_sqlite3.cpython-37m-darwin.so
Expected in: /usr/lib/libsqlite3.dylib in
/usr/local/Cellar/python/3.7.2_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload/_sqlite3.cpython-37m-darwin.so
what may cause the problem? I tried to download python source code and compile it, and move the _sqlite3.so or _sqlite3.cpython-37m-darwin.so file into the brew installed folder, and everything works just fine. Could brew just forget something in the formula? What can I do except for compiling .so file from source and manually solve the problem?
I finally find out where the bug hides.
All my macOS devices(including 2 Pros and 1 Air) are sharing the same .zshrc file, and for some reason, I add a
export DYLD_LIBRARY_PATH="/Users/myname/Library/Developer/Xcode/iOS DeviceSupport/10.0.1 (14A403)/Symbols/usr/lib/:/usr/lib/"
which ruins the build of python sqlite shared library file, for sqlite recently add a feature called '_sqlite3_enable_load_extension'.
when I removed the DYLD_LIBRARY_PATH to the outdated dir, and brew reinstall python everything is fine.
By the way, brew config and brew doctor provides no information about DYLD_LIBRARY_PATH. Next time I'll follow the rules and provide these informations.
Problem solved!
I've spent the day trying to get the h5py module of python working, but without success. I've installed HDF5 shared libraries, followed the instructions I could find on the web to get it right. But it doesn't work, below is the error message I get when trying to import the module into python. I tried installing through MacPorts too but again it wouldnt work.
I'm using Python27 32 bits (had too for another module, and thus installed the i386 HDF5 library... if that's right?)
Any help very welcome !
Thank you !
import h5py
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/h5py/__init__.py", line 1, in <module>
from h5py import _errors
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/h5py/_errors.so, 2): Symbol not found: _H5E_ALREADYEXISTS_g
Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/h5py/_errors.so
Expected in: flat namespace
in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/h5py/_errors.so
Check that you are not inside the h5py installation directory.
My advice, if you can, install h5py using Anaconda Distribution Open Data Science Core.
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.