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.
Related
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.
I have a script that will run locally, but not on my Ubuntu server. Other scripts work fine on both platforms, but this specific one throws a import error when I attempt to run it on Ubuntu.
root#ip-xxx-xx-xx-xxx:~# /usr/bin/python3.5 /opt/script_folder/main.py
Traceback (most recent call last):
File "/opt/script_folder/main.py", line 2, in <module>
import process
File "/opt/script_folder/process.py", line 25, in <module>
from tools.getImages import getImages
File "/opt/script_folder/tools/getImages.py", line 5, in <module>
from newspaper import Article
File "/usr/local/lib/python3.5/site-packages/newspaper/__init__.py", line 10, in <module>
from .api import (build, build_article, fulltext, hot, languages,
File "/usr/local/lib/python3.5/site-packages/newspaper/api.py", line 14, in <module>
from .article import Article
File "/usr/local/lib/python3.5/site-packages/newspaper/article.py", line 15, in <module>
from . import network
File "/usr/local/lib/python3.5/site-packages/newspaper/network.py", line 14, in <module>
from .configuration import Configuration
File "/usr/local/lib/python3.5/site-packages/newspaper/configuration.py", line 15, in <module>
from .parsers import Parser
File "/usr/local/lib/python3.5/site-packages/newspaper/parsers.py", line 10, in <module>
import lxml.etree
ImportError: No module named 'lxml.etree'
Other scripts work fine and I didn't have this problem until I tried using the newspaper library. I have attempted the following:
pip3 install --upgrade newspaper3k
pip3 install --upgrade lxml
adding /usr/local/lib/python3.5/site-packages to $PATH
running on and off of a virtual environment
importing lxml.etree directly within the script
running on python3.5 terminal -
no errors thrown
apt-get remove python3.5,
pip3 uninstall newspaper3k,
pip3 install newspaper3k,
apt-get install python3.5
checked permissions of site-packages folder
checked the default library path that python3.5 uses
ensured the hashbang #!/usr/bin/env python3.5 is at the top of all files
sudo apt-get install python-lxml
I'm stumped here. Any guidance would be much appreciated.
EDIT:
I have also followed the instructions listed here: https://newspaper.readthedocs.io/en/latest/
Everything downloaded correctly except the following:
root#ip-xxx-xx-xx-xxx:~# curl https://raw.githubusercontent.com/codelucas/newspaper/master/download_corpora.py | python3
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 100 657 100 657 0 0 9387 0 --:--:-- --:--:-- --:--:-- 10265
Traceback (most recent call last):
File "<stdin>", line 6, in <module>
File "/usr/local/lib/python3.5/site-packages/nltk/__init__.py", line 137, in <module>
from nltk.stem import *
File "/usr/local/lib/python3.5/site-packages/nltk/stem/__init__.py", line 29, in <module>
from nltk.stem.snowball import SnowballStemmer
File "/usr/local/lib/python3.5/site-packages/nltk/stem/snowball.py", line 32, in <module>
from nltk.corpus import stopwords
File "/usr/local/lib/python3.5/site-packages/nltk/corpus/__init__.py", line 66, in <module>
from nltk.corpus.reader import *
File "/usr/local/lib/python3.5/site-packages/nltk/corpus/reader/__init__.py", line 105, in <module>
from nltk.corpus.reader.panlex_lite import *
File "/usr/local/lib/python3.5/site-packages/nltk/corpus/reader/panlex_lite.py", line 15, in <module>
import sqlite3
File "/usr/local/lib/python3.5/sqlite3/__init__.py", line 23, in <module>
from sqlite3.dbapi2 import *
File "/usr/local/lib/python3.5/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ImportError: No module named '_sqlite3'
based on your post, it seems like the problem can be with ubuntu environment differing from your other (mac os?) local environments. I assume that you've gotten newspaper3k lib to install properly on Mac OS environments but not Ubuntu?
Perhaps try the guidance in this post first, ImportError: No module named '_sqlite3' in python3.3
I think the core issue is that your ubuntu env is missing some important underlying packages that these python libs require.
Or maybe:
apt-get install sqlite3
sqlite3 -version
apt-get install python-pysqlite2
apt-get install python-pysqlite2-dbg
apt-get install libsqlite3-dev
apt-get install sqlite
pip install pysqlite
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.
I tried to get atpy on python 2.7. I downloaded ATpy0.9.6 from
https://pypi.python.org/pypi/ATpy/0.9.6
then tar it, and run:
cd ATpy0.9.6
sudo python setup.py install
things seemed to work well.
But when I tried to import atpy on python, I got always this error message:
ImportError: No module named astropy.io
More precisely,
>>> import atpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/atpy/__init__.py", line 1, in <module>
from .basetable import Table, TableSet, VectorException
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/atpy/basetable.py", line 15, in <module>
from . import registry
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/atpy/registry.py", line 164, in <module>
from . import fitstable
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/atpy/fitstable.py", line 8, in <module>
from astropy.io import fits
ImportError: No module named astropy.io
>>>
Could anyone help me to figure out the problem?
Perhaps the 'atpy' package depends on another package called 'astropy.io' that you are missing? Yes here it is https://astropy.readthedocs.org/en/v0.1/index.html
It happens that downloading the tar balls from pypi.python.org is the wrong way to install Python packages. The right way (though the Python docs explain poorly), is to run a command like
pip install atpy
This command will install your package and all its dependencies.
If the command pip is missing, you have to install it, which is ironically really complicated.
In my case the solution was to install astropy
pip install --no-deps astropy
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