I am trying to install PIL on Mac OSX 10.7.4 but after several hours attempt couldn't succeed. All the time I have encountered the same problem provided detail in pastebin link below. Enlighten me!!
Setting
tbc:~ mystic$ which python
/Library/Frameworks/Python.framework/Versions/2.7/bin/python
Pastebin
I searched and tried from several sources:
One
Two
Three
Four (Stackoverflow)
Five
Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import Image
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named Image
>>> import PIL
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named PIL
>>>
Edited as suggested by jdi but still running through the same problem as shown in above pastebin link
tbc:jpeg-8c mystic$ xcode-select -version
xcode-select version 2003.
tbc:jpeg-8c mystic$ which xcode-select
/usr/bin/xcode-select
tbc:jpeg-8c mystic$ xcode-select -print-path
/Applications/Xcode.app/Contents/Developer
tbc:jpeg-8c mystic$
Further, I gave try with homebrew as suggested by the "the paul"
tbc:cellar mystic$ brew link jpeg
Linking /usr/local/Cellar/jpeg/8d... 3 symlinks created
tbc:cellar mystic$ brew install pil
Error: pil-1.1.7 already installed
tbc:cellar mystic$ brew uninstall pil
Uninstalling /usr/local/Cellar/pil/1.1.7...
tbc:cellar mystic$ brew install pil
==> Downloading http://effbot.org/downloads/Imaging-1.1.7.tar.gz
Already downloaded: /Library/Caches/Homebrew/pil-1.1.7.tar.gz
==> python setup.py build_ext
==> python setup.py install --prefix=/usr/local/Cellar/pil/1.1.7
==> Caveats
This formula installs PIL against whatever Python is first in your path.
This Python needs to have either setuptools or distribute installed or
the build will fail.
Warning: Non-executables were installed to "bin".
Installing non-executables to "bin" is bad practice.
The offending files are:
/usr/local/Cellar/pil/1.1.7/bin/pilfont.py
==> Summary
/usr/local/Cellar/pil/1.1.7: 174 files, 2.0M, built in 15 seconds
tbc:cellar mystic$ python
Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pil
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named pil
>>> from PIL import Image
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named PIL
Here is the log of .pip
Its complaining about
/Developer/SDKs/MacOSX10.6.sdk/usr/include/stdarg.h:4:25: error: stdarg.h: No such file or directory
but stdarg.h file is there at the same location.
I am not understanding why its trying to locate in MacOSX10.6.sdk as my current version of Lion isMacOSX10.7.sdk
Getting crazy!!!
If you are on Lion, using the newest XCode, then a potential problem for you is that they moved the location of the developer SDKs. Packages that expected them to live in /Developer/ would no longer find them as needed.
Reference this article about specifics:
http://www.agile-workers.com/web/2012/03/qt-qmake-osx_sdk-xcode/
But in summary, what you might need to do is run:
sudo /usr/bin/xcode-select -switch /Applications/Xcode.app/Contents/Developer
to point at the new location.
A manual fix might be to just symlink the SDK from /Applications/Xcode.app/Contents/Developer/... => /Developer/..., but I would first try the xcode-select tool.
Update: Some more suggestions based on your new updates
First off, I can't tell from what you posted whether PIL failed to build because of the SDK or not. If it built successfully, and you are using the standard apple python, then chances are the homebrew python path is not in your own python path.
$ python
>>> import sys
>>> sys.path.append("/usr/local/lib/python2.7/site-packages")
>>> from PIL import Image
If that still errors, then I suppose the issue is still related to missing SDK location.
You could symlink the new location of the SDK to the old one with:
mkdir -p -v /Developer/SDKs
ln -s /Applications/Xcode.app/Contents/Developer/MacOSX10.6.sdk /Developer/SDKs/MacOSX10.6.sdk
Or, you can try explicitly setting the the sdk path when you build pil:
brew remove pil
export SDKROOT=/Applications/Xcode.app/Contents/Developer/MacOSX10.6.sdk
brew install pil
Easy solution:
install Homebrew
brew install pillow
:)
If you have Homebrew installed, this will do the the job:
brew install pillow
Related
I am trying to install opencv package on Raspberry Pi (Stratodesk OS). the best shot I got so far is through: https://www.piwheels.hostedpi.com/simple
However, after installing
pip install opencv-contrib-python --extra-index-url https://www.piwheels.hostedpi.com/simple
when importing the cv2 in python I get import error message related to libhdf5_serial.so.100:
root#PNAR55:~# python3
Python 3.5.2 (default, Nov 12 2018, 13:43:14)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
import cv2
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.5/dist-packages/cv2/init.py", line 3,
in
from .cv2 import *
ImportError: libhdf5_serial.so.100: cannot open shared object file: No
such file or directory
besides, I tried to install opencv-python but without success
pip install opencv-python --extra-index-url https://www.piwheels.hostedpi.com/simple
when importing cv2, I am getting a different ImportError message related to liblapack.so.3
import cv2
Traceback (most recent call last): File "", line
1, in File
"/usr/local/lib/python3.5/dist-packages/cv2/init.py", line 3, in
from .cv2 import * ImportError: liblapack.so.3: cannot open shared object file: No such file or directory
for your information, Stratodesk OS is quite different that Raspbian. I do not have git, cmake, apt-get commands.
if there is a way to overcome the error messages I am getting
This problem is due to an incompatibility between your board and the OpenCV version. If you installed it via pip try pip uninstall opencv-python or pip3 uninstall opencv-python (depending of the python version you need (pip for python2 and pip for python3). After uninstaling is complete, try to search for an older version of opencv and install via pip3 install opencv-python==3.4.6.27 (this is the version that worked for me. I'm almost sure you'll need another one). Also, check this link, and this one!
I have installed xgboost successfully using pip for Python 2.7.16 (I installed this Python version using Homebrew on macOS High Sierra). My problem is that I'm unable to import xgboost in Python, as per the error message below:
mac-128644:~ user$ python
Python 2.7.16 (default, Apr 12 2019, 15:32:52)
[GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.11.45.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import xgboost
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/xgboost/__init__.py", line 11, in <module>
from .core import DMatrix, Booster
File "/usr/local/lib/python2.7/site-packages/xgboost/core.py", line 163, in <module>
_LIB = _load_lib()
File "/usr/local/lib/python2.7/site-packages/xgboost/core.py", line 154, in _load_lib
'Error message(s): {}\n'.format(os_error_list))
xgboost.core.XGBoostError: XGBoost Library (libxgboost.dylib) could not be loaded.
Likely causes:
* OpenMP runtime is not installed (vcomp140.dll or libgomp-1.dll for Windows, libgomp.so for UNIX-like OSes)
* You are running 32-bit Python on a 64-bit OS
Error message(s): ['dlopen(/usr/local/lib/python2.7/site-packages/xgboost/./lib/libxgboost.dylib, 6): Library not loaded: /usr/local/opt/gcc/lib/gcc/8/libgomp.1.dylib\n Referenced from: /usr/local/lib/python2.7/site-packages/xgboost/./lib/libxgboost.dylib\n Reason: no suitable image found. Did find:\n\t/usr/local/lib/python2.7/site-packages/xgboost/./lib/libxgboost.dylib/libgomp.1.dylib: stat() failed with errno=20']
I've made sure that both my Python version and OS are 64-bit, so the problem is definitely not the second "likely cause." I'm also pretty sure I have OpenMP installed: looking up instructions, for my case I would do brew install llvm and the install was successful. I'm also not sure why it can't seem to find /usr/local/lib/python2.7/site-packages/xgboost/./lib/libxgboost.dylib, as I can cd into that directory and see libxgboost.dylib just fine. It looks like later on in the message it did find it, but still throws an error? What exactly is going on here, and what can I do to fix this error?
Install xgboost first:
pip install xgboost
Then use:
brew install libomp
At last:
import xgboost as
Running my script (which imports ply) with python 2.7 works without issue. But trying to run the same script with python3 causes the following. (Note: I'm on v3.10 of ply - the latest which should be compatible with python3).
bos-mpqpu:config_parse rabdelaz$ python3 lexparse.py
Traceback (most recent call last):
File "lexparse.py", line 1, in <module>
import ply.lex as lex
ModuleNotFoundError: No module named 'ply'
bos-mpqpu:config_parse rabdelaz$ pip show ply | grep Version
Version: 3.10
I've installed python3:
bos-mpqpu:config_parse rabdelaz$ python3
Python 3.6.2 (v3.6.2:5fd33b5926, Jul 16 2017, 20:11:06)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ply
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'ply'
>>>
Try this command if you have pip3
pip3 install ply
This works too:
python3 -m pip install ply
You must install this module for python3.
Python modules, libraries are different for python 2 and 3.
for linux installation:
python 2.7.x : sudo apt-get install python-ply
python 3.x : sudo apt-get install python3-ply
https://www.howtoinstall.co/en/ubuntu/utopic/python-ply
I was facing the same issue but couldn't exactly know what was the problem so I again installed ply library and went to its location and made my project there. Library worked well there.
Install ply library
pip3 install ply
this would show you where the library is stored after successful installation.
Go to the location and make your project their.
This worked for me. Hopefully it would help you too.
I am working with python 3. My problem is that each time I install a package, it installs it for python2.
For example, I want to use mapnik, so I've just installed it with homebrew, and then it created a folder for python2.7 in mapnik lib.
So it works when I use Python2.7 but not with python3, cause it cannot find the module mapnik.
How can I add it to python 3 ?
python3 path : /Users/gabrielgautron/documents/python3
At the end of mapnik's installation I have the following :
For non-homebrew Python, you need to amend your PYTHONPATH like so:
export PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH
So I launch this command in terminal, and then :
MacBook-Pro-de-Gabriel-Gautron:local gabrielgautron$ python3
Python 3.2.4 (v3.2.4:1e10bdeabe3d, Apr 6 2013, 11:25:28)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import mapnik
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: No module named _mapnik
A idea ?
Please :)
Looking at the brew recipe, it depends on the version of python that's accessible when you run brew:
def which_python
"python" + `python -c 'import sys;print(sys.version[:3])'`.strip
end
So given that, you should change your PATH when invoking brew so that you're using python3 as python. For example:
# 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
I have installed scipy with port on my mac. it says all is fine:
$ sudo port install py-scipy
Password:
---> Computing dependencies for py-scipy
---> Cleaning py-scipy
but when i pull up python, it doesn't see it:
$ python2.6
Python 2.6.7 (r267:88850, Jul 27 2011, 11:54:59)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import scipy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named scipy
My path includes the port locations i've been able to find online:
... '/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python26.zip', '/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6', '/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-darwin', '/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac', '/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac/lib-scriptpackages', '/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk', '/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-old', '/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload', '/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages', '/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg-info', ...
In fact I can't find scipy files installed anywhere along the /opt/local/Library/Frameworks etc path.
Any ideas?
To change your current version of Python to the one installed with MacPorts:
sudo port select python python26
This should let you use the MacPorts version of Python that has scipy installed.
For more information search for macports.conf, you will have all the information there. You can also man macports.conf for some details.
The Python module that you installed isn't in the search path of the standard OS X version of Python. When you install a Python module using MacPorts it will install it's own version of Python. You can start using MacPort's version using the select command:
sudo port select python python26
Another option is to install it using the standard Python easy_install