Xgboost throws an error when trying to import - python

I have a project that is using xgboost. We now transfer the project to containers.
But after installing it using pip, it throws the following error:
Traceback (most recent call last):
File "restart_db.py", line 5, in <module>
from autoai.core.providers import GlobalEnrichmentProvider
File "/volumes/code/autoai/core/providers/__init__.py", line 1, in <module>
from .files_providers import CsvProvider, TsvProvider, ExcelProvider, FileProvider
File "/volumes/code/autoai/core/providers/files_providers.py", line 10, in <module>
from .base import BaseProvider, BaseInMemoryProvider
File "/volumes/code/autoai/core/providers/base.py", line 1, in <module>
from autoai.models.dataset_connection import JoinTypes
File "/volumes/code/autoai/models/__init__.py", line 5, in <module>
from .classifier import Classifier
File "/volumes/code/autoai/models/classifier.py", line 8, in <module>
from eli5 import explain_prediction
File "/volumes/dependencies/lib/python3.6/site-packages/eli5/__init__.py", line 53, in <module>
from .xgboost import (
File "/volumes/dependencies/lib/python3.6/site-packages/eli5/xgboost.py", line 9, in <module>
from xgboost import ( # type: ignore
File "/volumes/dependencies/lib/python3.6/site-packages/xgboost/__init__.py", line 11, in <module>
from .core import DMatrix, Booster
File "/volumes/dependencies/lib/python3.6/site-packages/xgboost/core.py", line 150, in <module>
_LIB = _load_lib()
File "/volumes/dependencies/lib/python3.6/site-packages/xgboost/core.py", line 141, in _load_lib
'Error message(s): {}\n'.format(os_error_list))
xgboost.core.XGBoostError: XGBoost Library (libxgboost.so) 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): ['libgomp.so.1: cannot open shared object file: No such file or directory']
I checked that both my python and my ubuntu are 64-bit, and ran:
apt-get update && apt-get install -y libaio1
To make sure that package is there (I read it somewhere that this might be the problem) - but it still throws the same error.
I've been stuck on this for a while now and will appreciate any help.

I had the same error with lightGBM, and to get around the issue i ran:
apt-get install libgomp1
This was required prior to any lightGBM code being called. The error for me occurred when unpickling a lightGBM model, not specifically when importing lightGBM.

I had this issue while creating Docker image of my project.
I have used the command below:
RUN apt-get update && \
apt-get -y --no-install-recommends install \
libgomp1

I had the same problem. Tried to fix both "likely" causes to no avail. Strangely, everything was working absolutely fine just a few days ago. I changed the Python version from 3.6.1 to 3.6.7 and it fixed the issue. Unfortunately, I don't yet know what the problem was, but it fixed the issue for me.
This is Python's docker image on CircleCi's linux machine. Specifying this in case the problem has to do anything with it.
Hope this helps someone!

Got this on my MacOS, and as the debug message suggests, brew install libomp fixed it.

Related

ModuleNotFoundError: No module named '_brotli' when trying to install dash

I try to install dash on a mac OS, and I have the following error when running 'import dash' on a python script:
Traceback (most recent call last):
File "app.py", line 16, in <module>
import dash
File "/Users/manuel/Library/Python/3.9/lib/python/site-packages/dash/__init__.py", line 5, in <module>
from .dash import Dash, no_update # noqa: F401,E402
File "/Users/manuel/Library/Python/3.9/lib/python/site-packages/dash/dash.py", line 17, in <module>
from flask_compress import Compress
File "/Users/manuel/Library/Python/3.9/lib/python/site-packages/flask_compress/__init__.py", line 1, in <module>
from .flask_compress import Compress
File "/Users/manuel/Library/Python/3.9/lib/python/site-packages/flask_compress/flask_compress.py", line 14, in <module>
import brotli
File "/Users/manuel/Library/Python/3.9/lib/python/site-packages/brotli.py", line 8, in <module>
import _brotli
ModuleNotFoundError: No module named '_brotli'
I can't figure it out what is the problem. I use python 3.7. I saw on the internet a similar issue on windows, but not on mac. I would be really grateful if you could help me.
You seem to have a broken installation of the brotli module (missing its native code component _brotli).
Try uninstalling it with pip uninstall brotli, then reinstall it; pip install brotli.
Going forward, I would heavily recommend you learn and use virtualenvs instead of installing everything into your Python's site-packages.
After uninstalling and installing again brotli it worked! Moreover, working in virtual environments is really more appropriate. Thank you a lot, AKX.

Error libtorch_python.so: cannot open shared object file: No such file or directory

I'm trying to implement fastai pretrain language model and it requires torch to work. After run the code, I got some problem about the import torch._C
I run it on my linux, python 3.7.1, via pip: torch 1.0.1.post2, cuda V7.5.17. I'm getting this error:
Traceback (most recent call last):
File "pretrain_lm.py", line 7, in <module>
import fastai
File "/home/andira/anaconda3/lib/python3.7/site-packages/fastai/__init__.py", line 1, in <module>
from .basic_train import *
File "/home/andira/anaconda3/lib/python3.7/site-packages/fastai/basic_train.py", line 2, in <module>
from .torch_core import *
File "/home/andira/anaconda3/lib/python3.7/site-packages/fastai/torch_core.py", line 2, in <module>
from .imports.torch import *
File "/home/andira/anaconda3/lib/python3.7/site-packages/fastai/imports/__init__.py", line 2, in <module>
from .torch import *
File "/home/andira/anaconda3/lib/python3.7/site-packages/fastai/imports/torch.py", line 1, in <module>
import torch, torch.nn.functional as F
File "/home/andira/anaconda3/lib/python3.7/site-packages/torch/__init__.py", line 84, in <module>
from torch._C import *
ImportError: libtorch_python.so: cannot open shared object file: No such file or directory
So I tried to run this line:
from torch._C import *
and got same result
ImportError: libtorch_python.so: cannot open shared object file: No such file or directory
I checked /home/andira/anaconda3/lib/python3.7/site-packages/torch/lib and there are only libcaffe2_gpu.so and libshm.so file, and I can't find libtorch_python.so either. My question is, what is actually libtorch_python.so? I've read some of article and like most of it talked about undefined symbol, not cannot open shared object file: No such file or directory like mine. I'm new at python and torch so I really appreciate your answer.
My problem is solved. I'm uninstalling my torch twice
pip uninstall torch
pip uninstall torch
and then re-installing it back:
pip install torch==1.0.1.post2
Try to use pytorch 1.4.0. For which, upgrade the pytorch library using the following command,
pip install -U torch==1.5
If you are working on Colab then use the following command,
!pip install -U torch==1.5
Still facing challenges on the library then install detectron2 library also.
!pip install detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cu102/torch1.9/index.html
I run into this error when I accidentally overwrite pytorch with a different channel. My original pytorch installation is from pytorch channel and in a later update it was overwritten with the one from conda-forge. I got this error even if the version is the same. After reinstalling pytorch from pytorch channel, the error is gone.

Trouble importing FENiCS Dolfin on Ubuntu 14.04

I am running Ubuntu 14.04, and python 2.7.6, and have had trouble running importing DOLFIN from FEniCS. I used the following commands to install, as suggested by FENiCS documentation:
sudo add-apt-repository ppa:fenics-packages/fenics
sudo apt-get update
sudo apt-get install fenics
sudo apt-get dist-upgrade
No errors occurred during installation, but when running the command
from dolfin import *
I get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/dolfin/__init__.py", line 16, in <module>
from . import cpp
File "/usr/lib/python2.7/dist-packages/dolfin/cpp/__init__.py", line 42, in <module>
exec("from . import %s" % module_name)
File "<string>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/dolfin/cpp/function.py", line 209, in <module>
class GenericFunction(ufc.function, common.Variable):
AttributeError: 'module' object has no attribute 'function'
Any help would be greatly appreciated. Thanks!
In case anyone comes across the same problem, I received a useful response to this here.
In short, somehow in my /etc/apt/sources.list.d/fenics-packages-fenics-trust.list file, I had this line for some reason:
deb http://ppa.launchpad.net/fenics-packages/fenics-exp/ubuntu trusty main
And the experimental builds are not compatible with Ubuntu 14.04. I manually changed 'fenics-exp' to 'fenics' and reinstalled, and it works now.

How to install Python 2.7 on Ubuntu 9.10

Now we're developing our software on the customer side, and there is:
maestro#UIServer:~$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=9.10
DISTRIB_CODENAME=karmic
DISTRIB_DESCRIPTION="Ubuntu 9.10"
system is installed. We're not allowed to upgrade this system to a newer version, but we need to use Python 2.7 in our project.
E.g. we have to use pymorphy2 package, but when we're trying to import it into project, we get:
>>> import pymorphy2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/pymorphy2/__init__.py", line 3, in <module>
from .analyzer import MorphAnalyzer
File "/usr/local/lib/python2.7/site-packages/pymorphy2/analyzer.py", line 10, in <module>
from pymorphy2 import opencorpora_dict
File "/usr/local/lib/python2.7/site-packages/pymorphy2/opencorpora_dict/__init__.py", line 4, in <module>
from .storage import load_dict as load
File "/usr/local/lib/python2.7/site-packages/pymorphy2/opencorpora_dict/storage.py", line 24, in <module>
from pymorphy2.utils import json_write, json_read
File "/usr/local/lib/python2.7/site-packages/pymorphy2/utils.py", line 5, in <module>
import bz2
ImportError: No module named bz2
Ok, we're trying to install libbz2-dev:
sudo apt-get install libbz2-dev
end getting this:
ValueError: /usr/bin/python does not match the python default version. It must be reset to point to python2.6
dpkg: error processing python-pip (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
python-pip
E: Sub-process /usr/bin/dpkg returned an error code (1)
How to avoid this problem?
Thanks in advance!
Download python, build and install using :
$ ./configure
$ make
$ make install
I am assuming you have build-essential installed or at least gcc. You can customize installation by passing prefix=/path/where/you/want/python/installed and other flags to make.

I installed PyOpenGl for python3, and when I import packages I get value errors

I wanted to start with some PyOpenGL, and so I booted into Mac Osx to try it. I went on the PyOpenGl website, downloaded the PyOpenGl and PyOpenGl_accelerate tars, cd'd into my downloads directory, and typed these commands into terminal to install:
tar -zxvf PyOpenGL-3.0.2.tar.gz
cd PyOpenGL-3.0.2
python3 setup.py install #I changed 'python' to 'python3' to install it to my python3.
next, i typed these to install the accelerate package
tar -zxvf PyOpenGL-accelerate-3.0.2.tar.gz
cd PyOpenGL-accelerate-3.0.2
python3 setup.py install #Again, 'python' replaced with 'python3'
Finally, I ran this code to test the install
python3
>>>from OpenGL.GL import *
which gave me this lovely string of errors
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/PyOpenGL-3.0.2-py3.3.egg/OpenGL/GL/__init__.py", line 3, in <module>
from OpenGL.GL.VERSION.GL_1_1 import *
File "/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/PyOpenGL-3.0.2-py3.3.egg/OpenGL/GL/VERSION/GL_1_1.py", line 10, in <module>
from OpenGL import platform, constants, constant, arrays
File "/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/PyOpenGL-3.0.2-py3.3.egg/OpenGL/arrays/__init__.py", line 19, in <module>
from OpenGL.arrays.arraydatatype import *
File "/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/PyOpenGL-3.0.2-py3.3.egg/OpenGL/arrays/arraydatatype.py", line 14, in <module>
from OpenGL_accelerate.arraydatatype import ArrayDatatype as ADT
File "arraydatatype.pyx", line 1, in init OpenGL_accelerate.arraydatatype (src/arraydatatype.c:9315)
File "wrapper.pyx", line 2, in init OpenGL_accelerate.wrapper (src/wrapper.c:10792)
ValueError: level must be >= 0
Any idea why it's acting up like this?
EDIT: managed to get pyopengl working for python3 with following command:
sudo pip-3.3 install PyOpenGL
So... problem solved I guess...
Answering my own question here, I managed to get PyOpenGL working with the command
sudo pip-3.3 install PyOpenGl

Categories

Resources