I am working with a group of people using Ubuntu 16.04 with Python 3.7.3 running Anaconda 2019.03.
For a new project I was trying to use VTK and the version installed was 8.2.0. Running the example from here:
https://lorensen.github.io/VTKExamples/site/Python/IO/ReadSTL/
produces an error "module 'vtk' has no attribute 'vtkSTLReader'".
In further investigation the vtk module only has 9 functions and attributes missing all the ones I am used to.
I moved to another machine where I was easily able to run the example. That machines was ubuntu 20.04 with Anaconda installed with python 3.65 and VTK 8.1.1. I updated anaconda with
conda update conda
conda update --all
This resulted in vtk getting updated to VTK 8.2.0 however now if I simply run a simple python code
import vtk
vtk.
The same thing happened as the work computer. The auto complete after typing period no longer gives a list of all the functions and attributes. And trying to run old code that worked gives errors that the functions and attributes are not available in vtk. I uninstalled vtk from conda and installedthe latest VTK version 9.0.1 using pip and the error is the same. Are there dependencies that don't get updated by conda when you update vtk?
Other things that I tested still work so it just seems like VTK broke. I looked through the API changes between vtk8.1.1 and 8.2.0 and although there are a few it doesn't change some of the ones that are missing like vtkRenderer() or vtkSTLReader().
I was able to go back to vtk8.1.1 and verify it works but I would really like to use vtk 8.2 or greater because there are a group of people using python 3.7 and it would be impractical to have them all move back to Python 3.65 for this.
I am basing the need for VTK >8.2 based on a post I read where python3.7 needs vtk >8.2.
Based on this article I also tried installing python-vtk7 but the package was not found for ubuntu 16.04.
Setting up VTK, with python3.8 and Ubuntu 20.04
I assume I have a mismatch with something simple but just not sure what. I would appreciate if anyone has any insight into if I need to update something else in addition to the conda update.
Adding a little more detail:
I tried pip install python-vtk as well. This installs python-vtk 0.1.0 and replaces vtk with version 8.1.2 with the same error messages. Moving back to python 3.65 and vtk 8.1.1 fixes the problem but I haven't been able to get any version to work with Python 3.7.
Update:
I asked for information through VTK as well.
https://discourse.vtk.org/t/installing-vtk-8-2-for-python-3-7-3-no-attributes-available/3821/4
I add a debug command in the vtk.py file. If I call the import vtk from a editor in spyder the debug does not get printed, but if I call the import vtk from the console in spyder it does. I have no idea why those two would be different.
Thanks
The issue ended up being my openGL support. I had three machines. One was running VMWARE which showed the issue. One was running VNC which showed the issue. And one was running ubuntu natively (using the GPU HW ) which worked fine.
I was running with VMWARE and that worked OK with python 2.x and earlier versions of VTK but when I moved to Python 3x and later versions of VTK it broke because it didn't support the right version of OpenGL. It looks like there are couple different ways to fix it, but in my case the one I used was to use a SW implementation of OpenGL to guarantee support. This was the fastest solution. The other solution would be with a virtual GL driver which leverages the HW and is likely faster and I will likely look at in the future.
For the SW implementation of OpenGL:
sudo apt install llvm-dev # make sure SW driver that supports OPENGL3.2
export LIBGL_ALWAYS_SOFTWARE=1 # Ensures vtk uses sw opengl driver: this needs to be called from each new terminal or alternatively make persistent in bashrc
Related
I have both Python 3.7 and 2.7 installed currently, and have a simple image processing script that calls for opencv. However, I keep getting the "module not found" error. I've tried using pip install, pip3 install, and installing the Windows executable from the opencv website, none of which have fixed the problem. The script won't run from either 3.7 or 2.7! I'm currently trying to use Visual Studio Code on a Windows 10 Surface computer.
Other threads seem to suggest that I need to update the Python registry/pointer or something to reflect the actual install location, but I can't seem to find how to do this. Or can I simply copy/paste the directory or files into Python directly? (Python 3.7 is preferred, or for both if possible!)
Edit: After uninstalling and reinstalling both Python 2.7 and 3.7, I think I figured out what the problem was! I was still having issues upon reinstall, so I tried rolling back a version to 3.6. During this installation, I noticed that even pip wasn't working anymore. It was at this point I realized that somehow my installation of Python was done with administrative privileges by default. Even though my account is the only one running on my personal computer, I still had to install pip with elevated privileges to get it to work. Now it seems like OpenCV and other modules are working!
I have Python 2.7.9 and OpenCV 3.1.0 installed on a Windows System. I'm using Spyder 2.3.2 and would love to access documentation for OpenCV in the IDE, however using Ctrl+I on cv2 functions/objects only shows No documentation available.
According to this question, OpenCV documentation should be available since Spyder 2.3.1.
Do I need to install additional modules, copy some files or update packages? If I need to upgrade Spyder, how do I do that? (it seems to be part of my pythonxy installation and the python setup on windows often seems so fragile that I'm hesitant to mess around with it)
Support for Jedi in Spyder was added in Spyder 2.3.3, released more than two years ago. Jedi is the library used to get completions and documentation from compiled modules like OpenCV.
The latest Spyder version is 3.1.0, which has better integration with Jedi, so I recommend you to update to that version instead.
However, I don't know how to do it using PythonXY, sorry. You should use the Anaconda distribution instead, which is more up to date than PythonXY.
On my OS(Linux Mint Debian Edition 2), except for the system python(/usr/bin/python) installed by the apt, I also installed the anaconda. But I've encounterd a problem running the following code with the anaconda python
# test.py
import matplotlib.pyplot as plt
import numpy as np
x = np.array([0, 1])
plt.scatter(x, x)
plt.show()
The error is
This application failed to start because it could not find or load the
Qt platform plugin "xcb".
Reinstalling the application may fix this problem.
Aborted
But if I try with the system python, i.e., /usr/bin/python test.py, it works correctly.
Then I tried the ipythons, of system and of anaconda, the result is same as before: the anaconda ipython kernel died.
And I tried add the ipython magic %matplotlib inline into the code, the anaconda ipython works correctly now. But if I replace the %matplotlib inline with %pylab, the anaconda ipython died again.
Note: I use the python 2.7. System ipython's version is 2.3, anaconda ipython's version is 3.2.
To fix this problem, I added to the top:
import matplotlib
matplotlib.use('Agg')
I have a CentOS7, Anaconda3-4.5.0, python3.5
pyqt version 5.6.0 and qt version 5.6.0
If you want to use the plot in a Tkinter window for visualisation then use:
matplotlib.use('TkAgg')
Same problem with Linux Mint 17, 64 bit. It was solved after 4h searching on the net! You need to give these commands on the terminal from folder /anaconda2/bin
sudo ./conda remove qt
sudo ./conda remove pyqt
sudo ./conda install qt
sudo ./conda install pyqt
Hope it helps!
I experienced this problem on Ubuntu 16.04 with anaconda 4.3.17 (Python 2.7). The issue stemmed from anaconda having Qt version 5.6 installed, while my system Qt libraries were at version 5.5.
A quick hack is to make sure Anaconda libraries precede your system libraries by setting LD_LIBRARY_PATH:
export LD_LIBRARY_PATH=$HOME/anaconda2/lib:$LD_LIBRARY_PATH
Unfortunately, this will break other programs that use Qt 5.5, so you can only use it in situations that are 100% anaconda python, for example, if you're starting an ipython session with --pylab.
I discovered that this was the issue by looking at the way libxqcb.so was linked:
ldd $HOME/anaconda2/plugins/platforms/libqxcb.so
which reported the following errors:
./libqxcb.so: /usr/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5: version `Qt_5_PRIVATE_API' not found (required by ./libqxcb.so)
./libqxcb.so: /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5: version `Qt_5' not found (required by ./libqxcb.so)
./libqxcb.so: /usr/lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5' not found (required by ./libqxcb.so)
./libqxcb.so: /usr/lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5.6' not found (required by ./libqxcb.so)
The error messages are saying they can't find Qt_5.6, which is anaconda's version. The version on my system was 5.5, which I found out by looking at the filenames that resulted from this command:
ls /usr/lib/x86_64-linux-gnu/libQt*
This can also happen when using something like an ssh session to connect to for instance a piece of software that is using X11 graphical libraries as I recently discovered.
The issue occurs when trying to plot images in the graphical user interface, using:
cv2.imshow()
or
plot.show()
In this case you should either use ssh -XY or you should consider saving to a file instead such as
cv2.imwrite('file.png')
or
plt.savefig('file.png')
I had this problem when using a deep neural network that was originally geared towards being used in conjunction with Jupyter notebook. When writing the images to files instead of displays, the code the ran through multiple ssh tunnels without reporting the xcb and Qt bug.
By the way, it didn't matter what variant of Qt4 or Qt5 was installed. It still failed with the same error message.
I had to upgrade several python packages to make it work. In particular:
pip3 install --upgrade pyside2 pyqt5
I've started to use python and recently i've bought my first mac.
I saw that Mountain Lion comes with their own python versions, despite i've decided to install a new python 2.7.5, and also Django and MySQL-Python. Everything works fine.
I've decided to try scipy and following the installed steps suggested by the official site with macports It seemed that macports installed another version 2.7.5 of python. Now if i try to run python in my terminal and import numpy it fails.
I saw that when i run python in my terminal, it execute
/Library/Frameworks/Python.framework/Versions/2.7/bin/python
But if I go in
cd /System/Library/Frameworks/Python.framework/Versions/2.7/bin
and run ./python i can import django and numpy modules but not MySQLdb modules.
I'm really confused how I can fix that mess.
I would like to have just one Python version installed in one place with all the modules I need.
Or please suggest something to clean that mess, know and have the control to what modules I have, where they are and how to import them! And also control which version of Python I want to run.
Edit 10/27/2013: i've solved following the link suggested in the comment, deleting all versions in /Library/ and all simlinks in /usr/local/bin, after that i changed to the path i wanted the py interpreter in my bash_profile.
Actually the problems seems to be created by macports that has installed numpy using the py interpreter installed under /System/, so i changed my default py interpreter to that installed under /System/ and installed the rest of packages i need. Now everything works as i want.
Personally, I wouldn't mess around with the built-in version of Python. I had some real issues with my Mac when I did that a few months ago.
You could try Canopy instead. It's a Python development environment which is great for writing and executing code. Any packages you need can be easily added (or removed) using the package manager. https://www.enthought.com/products/canopy/
I'm currently running Matplotlib 0.99.1.1 on Ubuntu 10.04 LTS (Lucid Lynx).
I would like to upgrade Matplotlib to version 1.1.0. I have tried following the
instructions at SourceForge, which didn't seem to do anything (IPython still thinks I have version 0.99.1.1).
I have tried searching for how to do this another way but, being relatively new to Linux, am a little confused what I need to do now. I have tried a few suggestions on the forums but still I cannot seem to install Matplotlib-1.1.0
This thread for example doesn't seem to work for me (pip complains of an "Unknown or unsupported command 'install'").
Any help is much appreciated!
Unless my memory fails me completely, I followed the build from source instructions you link to on two Lucid systems of mine. These instructions, to be precise:
http://matplotlib.sourceforge.net/users/installing.html#installing-from-source
Worked like a charm, after I remembered to do python setup.py install. And, yes,prior to the install, I removed the 0.99 matplotlib via synaptic. Did you try removing the older version first?
https://launchpad.net/ubuntu/oneiric/+source/matplotlib
There is a section for binary builds, just grab the appropriate package for your system architecture and dpkg -i the_package_name.deb
I'm not sure what went wrong with my system, but the issue resolved itself. Either one of the procedures I followed while searching for an answer worked, or the build from source instruction worked.
Perhaps my computer just took a while to realise I did in fact have the newest version installed.
For future reference, I would follow the install from source instructions on the matplotlib site at SourceForge, noting the answer by Zhenya.