vtkCommonCorePython missing error in python3-paraview on Ubuntu 20 - python-3.7

I'm trying to use paraview scripting within python3 for Ubuntu 20.04.1 LTS. If I open python3 on the command line I get the error
$> python3
Python 3.8.2 (default, Jul 16 2020, 14:00:26)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from paraview.simple import *
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3/dist-packages/paraview/simple.py", line 41, in <module>
from paraview import servermanager
File "/usr/lib/python3/dist-packages/paraview/servermanager.py", line 56, in <module>
from paraview.modules.vtkPVServerImplementationCore import *
File "/usr/lib/python3/dist-packages/paraview/modules/vtkPVServerImplementationCore.py", line 2, in <module>
from . import vtkPVClientServerCoreCore
File "/usr/lib/python3/dist-packages/paraview/modules/vtkPVClientServerCoreCore.py", line 2, in <module>
from . import vtkPVCore
File "/usr/lib/python3/dist-packages/paraview/modules/vtkPVCore.py", line 2, in <module>
from . import vtkClientServer
File "/usr/lib/python3/dist-packages/paraview/modules/vtkClientServer.py", line 3, in <module>
from .vtkClientServerPython import *
ImportError: Failed to load vtkClientServerPython: No module named vtkmodules.vtkCommonCorePython
>>>
I have python3-paraview, paraview, paraview-dev, vtk7, python3-vtk7, etc installed from the synaptic installation manager. There are two files with vtkCommonCorePython inside the dist-packages directory :
/usr/lib/python3/dist-packages/vtk/vtkCommonCorePython.cpython-38-x86_64-linux-gnu.so
/usr/lib/python3/dist-packages/vtkmodules/vtkCommonCorePython.cpython-38-x86_64-linux-gnu.so
Searching the internet shows that other people have had similar problems, and solved it but including the paths to vtkCommonCorePython, but sys.path does include /usr/lib/python3/dist-packages, so vtkCommonCorePython should be found.
Can anybody see what might be missing in this case?
Many thanks! John

There are (or at least there were in previous versions) some slightly tricky conflicts between the vtk and paraview packages in python. I've found it's best to keep paraview for python in its own conda environment.
Assuming you have conda already, you should be able to get up and running with:
conda create -n paraview -c conda-forge paraview

Related

conda pyqt import failed in a new virtual environment

I tried to run programs using pyqt.
It worked if I didn't use a virtual environment but if I activated a virtual environment, it would fail: ImportError: DLL load failed...
Traceback (most recent call last):
File "submitA2.py", line 14, in <module>
import matplotlib.pyplot as plt
File "C:\Users\jerem\Anaconda3\envs\deep\lib\site-packages\matplotlib\pyplot.py", line 116, in <module>
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "C:\Users\jerem\Anaconda3\envs\deep\lib\site-packages\matplotlib\backends\__init__.py", line 60, in pylab_setup
[backend_name], 0)
File "C:\Users\jerem\Anaconda3\envs\deep\lib\site-packages\matplotlib\backends\backend_qt5agg.py", line 16, in <module>
from .backend_qt5 import (
File "C:\Users\jerem\Anaconda3\envs\deep\lib\site-packages\matplotlib\backends\backend_qt5.py", line 18, in <module>
import matplotlib.backends.qt_editor.figureoptions as figureoptions
File "C:\Users\jerem\Anaconda3\envs\deep\lib\site-packages\matplotlib\backends\qt_editor\figureoptions.py", line 20, in <module>
import matplotlib.backends.qt_editor.formlayout as formlayout
File "C:\Users\jerem\Anaconda3\envs\deep\lib\site-packages\matplotlib\backends\qt_editor\formlayout.py", line 56, in <module>
from matplotlib.backends.qt_compat import QtGui, QtWidgets, QtCore
File "C:\Users\jerem\Anaconda3\envs\deep\lib\site-packages\matplotlib\backends\qt_compat.py", line 137, in <module>
from PyQt5 import QtCore, QtGui, QtWidgets
ImportError: DLL load failed: The specified procedure could not be found.
I can't install another pyqt package in this virtual environment because it tells me:
# All requested packages already installed.
# packages in environment at C:\Users\jerem\Anaconda3\envs\deep:
#
pyqt 5.6.0 py36_4 conda-forge
How to fix this?? Thanks.
A not perfect solution: installing a different version of PyQt5 seems to get around this issue.
activate myenv
conda install pyqt=5.9
Jeremy Chen's solution is the only solution that worked for me. i.e
conda install pyqt=5.9 within your conda environment
All other solutinos listed on internet did not work.
But this installation of pytqt=5.9 breaks matplotlib module with the following error when trying
import matplotlib
ImportError: cannot import name 'get_backend'
This was solved by using
conda uninstall matplotlib
and then reinstalling
conda install matplotlib

ImportError: No module named shutil_get_terminal_size IPython

I am having this error with my IPython version on Redhat.
$ ipython --version
Traceback (most recent call last):
File "/usr/bin/ipython", line 7, in <module>
from IPython import start_ipython
File "/usr/lib/python2.7/site-packages/IPython/__init__.py", line 48, in module
from .core.application import Application
File "/usr/lib/python2.7/site-packages/IPython/core/application.py", line 24, in <module>
from IPython.core import release, crashhandler
File "/usr/lib/python2.7/site-packages/IPython/core/crashhandler.py", line 28, in module
from IPython.core import ultratb
File "/usr/lib/python2.7/site-packages/IPython/core/ultratb.py", line 121, in module
from IPython.utils.terminal import get_terminal_size
File "/usr/lib/python2.7/site-packages/IPython/utils/terminal.py", line 27, in module
import backports.shutil_get_terminal_size
**ImportError: No module named shutil_get_terminal_size**
Could you please help me to resolve it?
According to this question, try:
conda config --add channels conda-forge
conda install backports.shutil_get_terminal_size
I got the same question as yours. I solve it by using pip install -U ipython to update IPython and it workes. Hope it helps!
If you don't want to use conda, try below.
pip install https://github.com/chrippa/backports.shutil_get_terminal_size/archive/159e269450dbf37c3a837f6ea7e628d59acbb96a.zip
None of the uninstalling/reinstalling stuff worked for me. What eventually worked for me was suggested by #ternus in a comment above: open up (on linux) /usr/local/lib/python2.7/dist-packages/IPython/utils/terminal.py and change the line
from backports.shutil_get_terminal_size import get_terminal_size as _get_terminal_size
to
from shutil_backports import get_terminal_size as _get_terminal_size
Reference: https://github.com/ipython/ipython/issues/9656
Author: https://github.com/ihincks
I follow this post
IPython console can't locate "backports.shutil_get_terminal_size" and won't load
to change /usr/lib/python2.7/site-packages/IPython/utils/terminal.py and it works for me
For me this worked (on Debian):
apt-get install python-ipython

Unable to import modules in Orange python environment but Orange GUI works

I would like to use the Orange.associate and Orange.data.sql modules in python scripting but in both cases I get AttributeError after import Orange.
However, in the Orange GUI both widgets work as expected.
When I check the python path with sys.path, the python interpreter has access to the Orange libraries, the global dist-packages and the local site-packages.
I have ubuntu 14.04 running and I installed Orange 3.3 into the /opt directory, following the instructions here:
http://orange.biolab.si/download/linux/
I am very unfamiliar with python environments and quite a beginner with Linux as well, so any hint is appreciated.
Here is an example of what I did:
(orange3env)bdukai#balazs-dukai:/opt/orange$ python
Python 3.4.3 (default, Oct 14 2015, 20:28:29)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import Orange
>>> Orange.data.sql
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'sql'
>>> Orange.data.Table
<class 'Orange.data.table.Table'>
Import in python does not import submodules (subpackages) automatically. If you want to use Orange.data.sql, you should import it directly:
>>> import Orange.data.sql
>>> Orange.data.sql
<module 'Orange.data.sql' from '.../Orange/data/sql/__init__.py'>

Virtualenv causing setuptools error

I am having trouble running a virtualenv, and I keep getting this same error code: "setuptools pip wheel failed with error code 1"
I saw some pages talking about how this is a discrepancy between different versions of setuptools, but I've uninstalled and reinstalled virtualenv and setuptools in several versions to no results. Does anyone know what's happening here?
Roberts-MacBook-Air:script Rob$ virtualenv venv
New python executable in venv/bin/python
Installing setuptools, pip, wheel...
Complete output from command /Users/Rob/Seedstages/script/venv/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip wheel:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/Rob/anaconda/lib/python2.7/site-packages/virtualenv_support/pip-7.1.2-py2.py3-none-any.whl/pip/__init__.py", line 13, in <module>
File "/Users/Rob/anaconda/lib/python2.7/site-packages/virtualenv_support/pip-7.1.2-py2.py3-none-any.whl/pip/utils/__init__.py", line 15, in <module>
File "/Users/Rob/anaconda/lib/python2.7/zipfile.py", line 6, in <module>
import io
File "/Users/Rob/anaconda/lib/python2.7/io.py", line 51, in <module>
import _io
ImportError: dlopen(/Users/Rob/Seedstages/script/venv/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyErr_ReplaceException
Referenced from: /Users/Rob/Seedstages/script/venv/lib/python2.7/lib-dynload/_io.so
Expected in: dynamic lookup
----------------------------------------
...Installing setuptools, pip, wheel...done.
Traceback (most recent call last):
File "/Users/Rob/anaconda/bin/virtualenv", line 11, in <module>
sys.exit(main())
File "/Users/Rob/anaconda/lib/python2.7/site-packages/virtualenv.py", line 832, in main
symlink=options.symlink)
File "/Users/Rob/anaconda/lib/python2.7/site-packages/virtualenv.py", line 1004, in create_environment
install_wheel(to_install, py_executable, search_dirs)
File "/Users/Rob/anaconda/lib/python2.7/site-packages/virtualenv.py", line 969, in install_wheel
'PIP_NO_INDEX': '1'
File "/Users/Rob/anaconda/lib/python2.7/site-packages/virtualenv.py", line 910, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /Users/Rob/Seedstages/script/venv/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip wheel failed with error code 1
Roberts-MacBook-Air:script Rob$
I would say that Anaconda causes the conflict, though to be more specific, it appears as if Anaconda's virtualenv is the problem. Running which virtualenv on my macbook (where I'm having the same problem) yields /Users/me/anaconda/bin/virtualenv while running it on the linux system I just tested this on yields /usr/local/bin/virtualenv.
So, on OS X, I downloaded virtualenv using /usr/local/bin/pip install virtualenv. This doesn't create a virtualenv binary (or it didn't for me) in the PATH folders, so I had to type this painfully long command:
sudo /usr/local/bin/python ... {the path to virtualenv.py in the system python's site-packages folder} new_env
And that did it. But that's ridiculous. No one wants to do that - even creating links would still be hacking it when you don't need to.
According to the ContinuumIO github page on this very subject, the virtualenv env and source /bin/activate commands are replaced with conda create -n env python=2.7 and source activate env.
Tested on my macbook (running Anaconda2 v4 on OS Yosemite) and it worked out.

bottle: can not import route

I am getting the following error:
(virtualenv)[chirdeep#fedora-desktop ~]$ python programs/python/myrestapi.py
Traceback (most recent call last):
File "programs/python/myrestapi.py", line 2, in <module>
import bottle
File "/home/chirdeep/programs/python/bottle.py", line 1, in <module>
from bottle import route, run
ImportError: cannot import name route
I have got python 2.7.3 and 3.2.3. (virtualenv) is pointing to python3 and I have installed bottle in here and its available under site-packges..
I can import bottle when I am under python console after activating the environment.
(virtualenv)[chirdeep#fedora-desktop ~]$ python
Python 3.2.3 (default, Jul 26 2012, 22:03:19)
[GCC 4.7.0 20120507 (Red Hat 4.7.0-5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import bottle
>>>
Any help will be much appreciated, driving me mad.
Thanks
Your own Python file is called bottle.py:
File "/home/chirdeep/programs/python/bottle.py", line 1, in <module>
So the real bottle.py is shadowed by your own file. Since your own file does not contain route and run, this fails:
from bottle import route, run
Rename your own file, perhaps mybottle.py.
I'm guessing the issue has to do with the collision of your program's namespace with bottle. I.e.: Python is trying to import route from /home/chirdeep/programs/python/bottle.py rather than the bottle.py in site-packages.
Try renaming your program file.