Python (homebrew) returns error on Sqlite - python

I have Python 2.7.6 and Python 3.3.4 installed through homebrew. I ran into some errors when trying to use Sqlite and I traced the error to a "symbol not found" error. Please see the trace below.
How can I get this thing to work?
>>> import sqlite3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sqlite3/__init__.py", line 24, in <module>
from dbapi2 import *
File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ImportError: dlopen(/usr/local/Cellar/python/2.7.6/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.7.6/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.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_sqlite3.so
edit: Sqlite3 also seems to be properly installed (sqlite-3.8.3 already installed).
On a sidenote, why does homebrew stick with Python 2.7.6 while the Python website offers version 2.7.8 for download?

You need to run brew update; both the sqlite formula and the python formula have seen numerous updates.
Python 2.7.8 has been available since July 2nd, for example. Your SQLite problems have probably long been solved with updates as well.
It is always a good idea to run brew doctor when you are having problems with Homebrew-supplied software; the output would have told you to run brew update too:
$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!
Warning: Your Homebrew is outdated.
You haven't updated for at least 24 hours. This is a long time in brewland!
To update Homebrew, run `brew update`.

Related

No module named 'index' after install pyflann

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

MySQLdb is hard to locate

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 import Python packages

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.

Cannot get mapnik working with python3, but it does with python2

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.

MySQLdb for Python - incompatible library version error?

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.

Categories