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
Related
I am trying to install Numba on a cluster so I can run my Jitted python codes on there. However I keep running into an error with "libllvmlite.so" when I try to import Numba. This is done on the Cedar cluster using virtualenv. Numba is installed using pip (and also tried pip3).
I start off my activating my enviroment using (... is the directory to my enviroment folder) :
source ~/.../ENV/bin/activate.
Then I use pip to install Numba (I've also tried used pip uninstall to remove and reinstall Numba).
However when I load up Python 3.7.0 on my enviroment, I obtain an error whenever I try to import Numba.
I use pip show to check versions: Python 3.7.0, Numba 0.53.1, llvmlite 0.36.0.
Here is the output of my terminal:
(ENV) [04:12:46] patrick7#cedar1 > [~/projects/def-mann/patrick7/diffusioncluster]python
Python 3.7.0 (default, Sep 25 2018, 18:19:16)
[GCC 5.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numba
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/patrick7/projects/def-mann/patrick7/diffusioncluster/ENV/lib/python3.7/site-packages/numba/__init__.py", line 19, in <module>
from numba.core import config
File "/home/patrick7/projects/def-mann/patrick7/diffusioncluster/ENV/lib/python3.7/site-packages/numba/core/config.py", line 16, in <module>
import llvmlite.binding as ll
File "/home/patrick7/projects/def-mann/patrick7/diffusioncluster/ENV/lib/python3.7/site-packages/llvmlite/binding/__init__.py", line 4, in <module>
from .dylib import *
File "/home/patrick7/projects/def-mann/patrick7/diffusioncluster/ENV/lib/python3.7/site-packages/llvmlite/binding/dylib.py", line 3, in <module>
from llvmlite.binding import ffi
File "/home/patrick7/projects/def-mann/patrick7/diffusioncluster/ENV/lib/python3.7/site-packages/llvmlite/binding/ffi.py", line 191, in <module>
raise OSError("Could not load shared object file: {}".format(_lib_name))
OSError: Could not load shared object file: libllvmlite.so
I have tried other solutions found online (reinstall, try different versions...), so far none has worked. Any help would be greatly appreciated! Thanks!
I figured out the solution to my problem.
What I've tried and didn't work:
Install llvmlite using pip manually
Downgrade to Numba version 0.43 since its the oldest version compatible with Python 3.7
Uninstall (llvmlite numpy and numba) and reinstalling Numba (which automatically installs it's dependancies) after upgrading Pip to the latest version
What worked:
Upgrading Python from 3.7.0 to 3.7.10
It seems like for Python version >= 3.7.3, the default command pip install numba works flawlessly!
Thanks for reading!
I have multiple pythons installed in my machine, 2.7, 3.5, 3.6, etc and I installed the library called spacy.
And it seems like this library keeps referring to the old version of python which is 3.5. at /usr/local/lib/python3.5/dist-packages.
Python 3.6.5 (default, Mar 29 2018, 03:28:50)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import spacy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/dist-packages/spacy/__init__.py", line 4, in <module>
from . import util
File "/usr/local/lib/python3.5/dist-packages/spacy/util.py", line 4, in <module>
import ujson
ModuleNotFoundError: No module named 'ujson'
Regardless of this specific library 'spacy', I'd like to know
what is the best way to make library to point to upgraded python which is 3.6, not 3.5. Which path variable should I update?
Please help... I've been wasting too much time on this issue.
Try to install spacy lib by running pip with required python version in module mode:
python3.6 -m pip install spacy
wonder if anyone has tried IntelPython with anaconda. i created an environment as in url link
Intel Python
however, when i try to import pytables, i get: -
(intelpython) dc#dcpctw:/opt/anaconda3/bin$ python
Python 3.5.3 |Intel Corporation| (default, Apr 27 2017, 18:08:47)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-15)] on linux
Type "help", "copyright", "credits" or "license" for more information.
Intel(R) Distribution for Python is brought to you by Intel Corporation.
Please check out: https://software.intel.com/en-us/python-distribution
>>> import tables
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'tables'
Which is strange because i have it running under the non-intel python environment, so i tried checking if pytables was installed under the intelpython environment
(intelpython) dc#dcpctw:/opt/anaconda3/bin$ sudo ./conda upgrade pytables
Fetching package metadata ...........
Solving package specifications: .
# All requested packages already installed.
# packages in environment at /opt/anaconda3:
#
pytables 3.3.0 np112py35_intel_2 [intel] intel
(intelpython) dc#dcpctw:/opt/anaconda3/bin$
So its installed in the environment and should work, any help? thanks
You are running the python executable from /opt/anaconda/bin but you have an activated environment of (intelpython). Change to a different directory, e.g., ~, make sure the first python on your PATH is /opt/anaconda3/envs/intelpython/bin/python, and try the import again.
I'm trying to install Tensorflow (r1.2) on my MacBook (OSX 10.12.5).
The installation works, but I'm getting errors, when I try to import TF in python.
Python 2.7.10 (default, Feb 7 2017, 00:08:15)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "tensorflow/python/pywrap_tensorflow.py", line 52, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
ImportError: No module named pywrap_tensorflow_internal
Failed to load the native TensorFlow runtime.
I'm working in a virtualenv (using virtualenvwrapper) with up-tp-date packages
python 2.7.10
pip 9.0.1
numpy 1.13.1
wheel 0.29.0
six 1.10.0
I tried to install the default pip package (no GPU support) using pip install tensorflow, first.
Afterwards I also tried to install tensorflow from source following the installation tutorial, without CUDA support (configure script said No CUDA support will be enabled for TensorFlow). Building and installing reported no errors, but I got the same error when I tried to import tensorflow.
Related questions/answers pointed out problems with CUDA or missing Windows dll files, which do not seem to fit my problem.
Any help is welcome. Thanks in advance.
I have the same problem.i did this
First
pip uninstall tensorflow
Download this tensorflow wheel file
Now install this using(in same Directory)
pip install tensorflow-1.6.0-cp36-cp36m-win_amd64.whl
My answer is same to yours.
I deleted the tensorflow with "rm -r ~/tensorflow ",
and finally it working when I have reinstalled it
The detail is here:https://www.tensorflow.org/install/install_mac#CommonInstallationProblems
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