Trouble importing FENiCS Dolfin on Ubuntu 14.04 - python

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.

Related

Xgboost throws an error when trying to import

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.

In OS X,every command of pip executing will appear the same Error,what can I do?

The Error is following:
Traceback (most recent call last):
File "/usr/local/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/Library/Python/2.7/site-packages/pkg_resources/__init__.py", line 72, in <module>
import packaging.requirements
File "/Library/Python/2.7/site-packages/packaging/requirements.py", line 59, in <module>
MARKER_EXPR = originalTextFor(MARKER_EXPR())("marker")
TypeError: __call__() takes exactly 2 arguments (1 given)
I tried to install jupyter by using pip,but it was failed.Then I reboot my mac,and executing csrutil disable in the terminal.Actually,I dont know what's mean.Finally I find my pip cannot used.I tried to uninstall it,also failed,until the Error which has been posted.
Any help is appreciated,thanks a lot in advance.
Back up this requirements.py file and modify it:
/Library/Python/2.7/site-packages/packaging/requirements.py
Remove the parentheses MARKER_EXPR,:
#MARKER_EXPR = originalTextFor(MARKER_EXPR())("marker")
MARKER_EXPR = originalTextFor(MARKER_EXPR)("marker")
Or you can upgrade pip:
python -m pip install --upgrade --force pip
Hope this helps.

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

ImportError: cannot import name ResourceError

I'm trying to install couchdb app on debian using the following command
couchapp push http://user:pass#localhost:5984/acra-appname
and I'm having the following error output:
Traceback (most recent call last):
File "/usr/local/lib/python2.6/dist-packages/restkit/__init__.py", line 9, in <module>
from restkit.conn import Connection
File "/usr/local/lib/python2.6/dist-packages/restkit/conn.py", line 14, in <module>
from socketpool import Connector
ImportError: No module named socketpool
Traceback (most recent call last):
File "/usr/local/bin/couchapp", line 7, in <module>
from couchapp.dispatch import run
File "/usr/local/lib/python2.6/dist-packages/couchapp/dispatch.py", line 10, in <module>
import couchapp.commands as commands
File "/usr/local/lib/python2.6/dist-packages/couchapp/commands.py", line 15, in <module>
from couchapp import clone_app
File "/usr/local/lib/python2.6/dist-packages/couchapp/clone_app.py", line 15, in <module>
from couchapp.errors import AppError
File "/usr/local/lib/python2.6/dist-packages/couchapp/errors.py", line 7, in <module>
from restkit import ResourceError
ImportError: cannot import name ResourceError
As far as I understand the error is:
ImportError: No module named socketpool
How can I install this module or how to resolve the problem?
As Ifthikhan sugessted: Install it using a package manager such as apt-get and thereafter using pip you can install socketpool.
I had this problem when installing couchapp. I used pip to install it, and I thought it completed, but when I ran it I had the ImportError problem. Turns out the pip install didn't succeed and I first needed to:
apt-get install python-dev
Then when I did a
pip install couchapp
all of the dependencies were installed and couchapp ran without a problem.

Categories

Resources