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
Related
I'm trying to install OpenCV on my raspberry pi 3(I'm using this tutorial https://linuxize.com/post/how-to-install-opencv-on-raspberry-pi/) after installation finished, I check it using the c++ library the module OpenCV has been installed
pi#raspberrypi:~ $ pkg-config --modversion opencv4
4.5.5
and when I use the python library the result is
pi#raspberrypi:~ $ python3
Python 3.9.2 (default, Mar 12 2021, 04:06:34)
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'cv2'
>>>
and then I check-in /usr/local/lib/python3.9/site-packages
pi#raspberrypi:/usr/local/lib/python3.9/site-packages $ ls
cv2
I have a strange problem on python2.7.6 with Ubuntu :
my python 2.7.6 is installed but strangely time module is not working. my ubuntu version is 16.04
i tried installing python 2.7.16 as well but that didnt fixed the issue as
/usr/local/bin# python2.7
Python 2.7.6 (default, Jul 22 2019, 12:49:04)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import time
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named time
expected : import time should work
actual : ImportError: No module named time
How do i import time in python 2.7.6
output of :
: ls /usr/lib/python2.7/lib-dynload/
audioop.i386-linux-gnu.so _codecs_tw.i386-linux-gnu.so dl.i386-linux-gnu.so _lsprof.i386-linux-gnu.so Python-2.7.egg-info
audioop.x86_64-linux-gnu.so _codecs_tw.x86_64-linux-gnu.so _elementtree.i386-linux-gnu.so _lsprof.x86_64-linux-gnu.so readline.i386-linux-gnu.so
_bsddb.i386-linux-gnu.so crypt.i386-linux-gnu.so _elementtree.x86_64-linux-gnu.so mmap.i386-linux-gnu.so readline.x86_64-linux-gnu.so
_bsddb.x86_64-linux-gnu.so crypt.x86_64-linux-gnu.so fpectl.i386-linux-gnu.so mmap.x86_64-linux-gnu.so resource.i386-linux-gnu.so
bz2.i386-linux-gnu.so _csv.i386-linux-gnu.so fpectl.x86_64-linux-gnu.so _multibytecodec.i386-linux-gnu.so resource.x86_64-linux-gnu.so
bz2.x86_64-linux-gnu.so _csv.x86_64-linux-gnu.so future_builtins.i386-linux-gnu.so _multibytecodec.x86_64-linux-gnu.so _sqlite3.i386-linux-gnu.so
_codecs_cn.i386-linux-gnu.so _ctypes.i386-linux-gnu.so future_builtins.x86_64-linux-gnu.so _multiprocessing.i386-linux-gnu.so _sqlite3.x86_64-linux-gnu.so
_codecs_cn.x86_64-linux-gnu.so _ctypes_test.i386-linux-gnu.so _hashlib.i386-linux-gnu.so _multiprocessing.x86_64-linux-gnu.so _ssl.i386-linux-gnu.so
_codecs_hk.i386-linux-gnu.so _ctypes_test.x86_64-linux-gnu.so _hashlib.x86_64-linux-gnu.so nis.i386-linux-gnu.so _ssl.x86_64-linux-gnu.so
_codecs_hk.x86_64-linux-gnu.so _ctypes.x86_64-linux-gnu.so _hotshot.i386-linux-gnu.so nis.x86_64-linux-gnu.so termios.i386-linux-gnu.so
_codecs_iso2022.i386-linux-gnu.so _curses.i386-linux-gnu.so _hotshot.x86_64-linux-gnu.so ossaudiodev.i386-linux-gnu.so termios.x86_64-linux-gnu.so
_codecs_iso2022.x86_64-linux-gnu.so _curses_panel.i386-linux-gnu.so imageop.i386-linux-gnu.so ossaudiodev.x86_64-linux-gnu.so _testcapi.i386-linux-gnu.so
_codecs_jp.i386-linux-gnu.so _curses_panel.x86_64-linux-gnu.so _json.i386-linux-gnu.so parser.i386-linux-gnu.so _testcapi.x86_64-linux-gnu.so
_codecs_jp.x86_64-linux-gnu.so _curses.x86_64-linux-gnu.so _json.x86_64-linux-gnu.so parser.x86_64-linux-gnu.so
_codecs_kr.i386-linux-gnu.so dbm.i386-linux-gnu.so linuxaudiodev.i386-linux-gnu.so pyexpat.i386-linux-gnu.so
_codecs_kr.x86_64-linux-gnu.so dbm.x86_64-linux-gnu.so linuxaudiodev.x86_64-linux-gnu.so pyexpat.x86_64-linux-gnu.so
It seems time package is not install, you can try by installing time package using below command.
pip install times
or
sudo pip install times.
and then try?
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 have successfully installed gnureadline using both pip (2.x) and pip-3.5. Although importing it in Python2.7 works perfectly, in Python 3.5 it throws the following exception:
Python 3.5.1 (default, Jan 31 2016, 04:03:04)
[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.
>>> import gnureadline
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dlopen(/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gnureadline.so, 2): Symbol not found: _PyInt_AsLong
Referenced from: /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gnureadline.so
Expected in: flat namespace
in /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/gnureadline.so
The weird thing is that python looks for the package in the Python2.7 path.
The platform is OSX 10.11.3.
You have to check your PYTHONHOME env variable.
check it with echo $PYTHONHOME, it should point to 3.5 version ,
if it's not true, fix it by the following command
export PYTHONHOME=/full path to appropriate python libs/
After checking the sys.path variable as BasicWolf pointed out, I noticed that the 2.7 site packages were included independent of the python version that I run. This happened due to an override of the PYTHONPATH env variable in my .bashrc file:
export PYTHONPATH=~/Library/Python/2.7/lib/python/site-packages/
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.