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
Importing the numpy c-extensions failed
I installed python 3.7 on my windows system to work on visual studio code. Everything was going well, including using the libraries.
I uninstalled python using the uninstalling program tool in control panel. And installed Miniconda 3.
I checked that everything works well, and then installed the numpy library using conda install numpy in my terminal GitBash on windows 10, then checked it on my visial studio code, but it failed to start.
Reproducing code example:
import numpy as np
A = np.array([[-1], [7], [-26]])
Error message:
Traceback (most recent call last): File
"C:\Users\ramim\Miniconda3\lib\site-packages\numpy\core__init__.py",
line 17, in
from . import multiarray File "C:\Users\ramim\Miniconda3\lib\site-packages\numpy\core\multiarray.py",
line 14, in
from . import overrides File "C:\Users\ramim\Miniconda3\lib\site-packages\numpy\core\overrides.py",
line 7, in
from numpy.core._multiarray_umath import ( ImportError: DLL load failed: Не найден указанный модуль.
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"c:/Users/ramim/Desktop/22/Matrix library/alsf.py", line 3, in
import numpy as np File "C:\Users\ramim\Miniconda3\lib\site-packages\numpy__init__.py", line
142, in
from . import core File "C:\Users\ramim\Miniconda3\lib\site-packages\numpy\core__init__.py",
line 47, in
raise ImportError(msg) ImportError:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy c-extensions failed.
- Try uninstalling and reinstalling numpy.
- If you have already done that, then:
1. Check that you expected to use Python3.7 from "C:\Users\ramim\Miniconda3\python.exe",
and that you have no directories in your PATH or PYTHONPATH that can
interfere with the Python and numpy version "1.17.3" you're trying to use.
2. If (1) looks fine, you can open a new issue at
https://github.com/numpy/numpy/issues. Please include details on:
- how you installed Python
- how you installed numpy
- your operating system
- whether or not you have multiple versions of Python installed
- if you built from source, your compiler versions and ideally a build log
If you're working with a numpy git repository, try git clean -xdf (removes all files not under version control) and rebuild numpy.
Note: this error has many possible causes, so please don't comment on
an existing issue about this - open a new one instead.
Original error was: DLL load failed: Не найден указанный модуль.
Numpy/Python version information:
Python 3.7.5
Numpy 1.17.3
I tried to uninstall and install the numpy library again, but it was useless.
Note: when I type in the teminal conda install numpy, it says:
All requested packages already installed
That's how I checked if numpy is really installed!
How to solve that?
Try to uninstall numpy and setuptools first:
pip uninstall -y numpy
pip uninstall -y setuptools
pip install setuptools
pip install numpy
Borrowed from solution provided by mehdiHadji here- https://github.com/ipython/ipyparallel/issues/349
Not sure this is a thing in Visual Studio too, but for Eclipse I had to change one of the environmental variables.
Setup: Windows, Python 3.7, Conda venv with numpy
Solution:
CONDA_DLL_SEARCH_MODIFICATION_ENABLE=1
For Eclipse, the environment variables can be accessed via Properties -> Run/Debug Settings -> Edit -> Environment.
Anaconda also documented the fix, albeit for a different problem:
Conda Troubleshooting
Similar with my problem recently. I'm using Python 3.8 by Miniconda on Win 10 system. I solved the problem by changing default terminal from PowerShell to Command Prompt.
Steps:
Open VS Code's Command Palette menu by pressing Ctrl+Shift+P or F1
Choose "Terminal: Select Default Profile" entry
Then pick "Command Prompt" option
Restart VS Code
This issue is caused by VScode default terminal (powershell) setting,
To switch VScode default terminal from powershell to cmd, the conda env will be activated correctly, other powershell will try to invoke conda activate xxxxxx which will fail, then the subsequent import numpy will fail.
So two ways to fix it:
Fix path search issue under powershell environment to get conda activate xxxxxx successfully executed;
Change vs code default terminal to 'cmd':
add "terminal.integrated.shell.windows": "C:\Windows\System32\cmd.exe" in settings.json
I solved this by the following steps-
Uninstalling numpy and pandas with conda
Installing numpy and pandas with pip
I solved the problem by reinstalling NumPy through pip:
pip install --upgrade --force-reinstall numpy
I solved it by removing ALL numpy versions
pip uninstall numpy
pip3 uninstall numpy
And then installing numpy and libatlas-base-dev via apt-get
sudo apt-get remove python3-numpy
sudo apt-get install libatlas-base-dev
It looks like there's something wrong with your %PATH%. It might either contain some conflicts, or just be too long (>2047 chars). Try adding the folder with the dlls (from the environment you're trying to use) to the very beginning of it:
PATH=C:\Users\ramim\Miniconda3\Library\bin;%PATH%
python -c "import numpy"
(based on this)
For those scratching their head wondering why re-installing numpy module works:
If you are using a virtual environment (say in a relative location called env), make sure that folder does not make it to other platforms like Docker, or different OS you might be switching to.
Remember the compilation of Python and C extensions necessary for numpy are platform dependent. So if it works in Windows, it will not work in Linux using the same virtual environment (cached modules).
For example, this is particularly important if you are running your code on Windows - and then try to run it on a Linux container via Docker Desktop. (Make sure env - or whatever your virtual env is called - is ignored and not copied onto the container)
I had the same problem, and tried several of the solutions given here, but none worked for me. I looked in another forum and was able to solve the problem (https://github.com/numpy/numpy/issues/13252):
conda uninstall numpy
pip3 install numpy.
This issue is still ongoing. I use VS code with conda venv, and solved it in a similar way with marineCoder:
In addition to numpy and pandas, I also remove matplotlib using conda uninstall
Cautiously reinstall pandas and numpy using pip install
In my case, the error shows up whenever matplotlib package is installed, so I got to either remove it or downgrade the three of them. There is a clash on numpy dependency. Another related issue is shown in this post:
I get `No module named _multiarray_umath` when using matplotlib
In my case, I had to manually 'conda activate myenv' the desired environment in the VS code terminal. Previously, I only had to select the python version from the desired environment, and then the environment would auto-activate. This answer references and confirms Brett Cannon's comment above, which was the sole reason I thought to try it.
As I'm on MacOS (with an M1 CPU) I realize my answer is not exactly an answer to the poster's question but as I got the same error and Google sent me here perhaps this helps someone.
In my case I found the error was caused because VSCode was still running in Intel-X86 mode on my Mac-M1. Simply re-installing VSCode using the latest "Mac Universal" distribution switched it to ARM64 mode fixing the issue for me.
Uninstalled anaconda and installed latest version
I tried the answers here but they didn't work for me, uninstalled older version of anaconda (don't remember previous version number now) and installed Anaconda3-2022.05 (Anaconda Navigator 2.1.4). This sorted it for me. I hadn't used my anaconda setup in long time and thus didn't care if my preinstalled packages get wiped out. This took a lot less time and saved from pain of trying more approaches.
OS: Windows 10
Please check both of these (your PATH or PYTHONPATH environment variables) carefully to see if they are what you expect.
In my case, there was an issue related to updated versions of python and NumPy, I resolved both problems by running a single command over conda PowerShell prompt i.e. conda update --all
Here are the steps-
Open Anaconda Powershell Prompt and click 'run as Administrator'.
Enter the following code into the prompt and click enter: conda update --all ...
You are all set to run your script
I hit this error while running a block of code in a .ipynb Jupyter Notebook file.
I fixed the problem by switching the version of Python that was running. Specifically, I was running Python 3.8.5 from the Anaconda3 directory on my computer and I switched this to Python 3.9.2 that I had installed elsewhere on my computer.
To toggle the version of Python in VSCode while working on a .ipynb file, click on the version specified in the top-right corner of the screen. Thereafter, a dropdown menu will allow you to select from different versions of Python installed on your computer.
For my situation, I had updated the version of python that I was using. Running git clean -xdf resolved the issue.
My system:
OS: Mac OS 11.6
Python: 3.7.8 => 3.8.12
Numpy: 1.20.2
Poetry: 1.1.6
I've installed the latest version of Anaconda. The install went smoothly, but when I try to run Spyder I get a couple of run-time errors relating to PySide and PyQt. The final error message is:
RuntimeError: Please check Spyder installation requirements:
PyQt4 4.6+ (or PySide 1.2.0+) is required.
However, when I try to install PyQt, Ubuntu says I have the most up to date version. Also, conda list indicates that I have the following installed (I've excluded the other stuff as it isn't relevant):
pyqt 4.11.4 py35_1
qt 4.8.7 1
So Ubuntu seems to recognise that I have PyQt installed, but Spyder can't 'see' it.
To fix this, I attempted to install spyder3 via the package manager using
sudo apt-get install spyder3
The install completed without any errors, but running spyder3 led to the same PyQt error as before.
Could someone please advise me how to fix this? I'm fairly new to Ubuntu, so am not sure how to link Spyder to the required Qt files.
Finally managed to fix this and figured it was worth posting an update in case anyone else has the same issue.
After installing Anaconda I installed some 3rd party software (moose framework) which requires a series of modules to be loaded. One of these is miniconda.
The presence of miniconda seems to confuse Spyder - and stops it from working. By using:
module unload miniconda
I found that Spyder works as normal.
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 am trying to install the Scipy python stack, but having issues.
I have a new mac os with mavericks (10.9).
I have installed homebrew and am using brew to manage installations.
I used
% brew install python
then (I verified pip is from my homebrew installation)
% pip install numpy [this works]
% pip install scipy [this works]
% pip install matplotlib OR pip install http://downloads.sourceforge.net/project/matplotlib/matplotlib/matplotlib-1.3.1/matplotlib-1.3.1.tar.gz
Both fail with the same error. After checking the backend, I get
Fatal Python error: PyThreadState_Get: no current thread
The error message from mac os X (the pop up error window) shows errors very similar to those in the previous thread
Homebrew + Python on mac os x 10.8: Fatal Python error: PyThreadState_Get: no current thread importing mapnik
It seems I need to fix the python bindings, as some of them linked against the /System/Library python that ships with the mac. What is not clear to me from the above post is
which of the Binary Images need to be "re-linked"? all of them? some seem quite general an not related to matplotlib
how do I actually use install_name_tool to fix the link? As I mentioned, some seem quite general - do I really want to change the path? Do I cp the dylib from old to new?
I have also tried
brew uninstall python
and re-brewing, all to get the same error. I am trying not to use EPD because EPD installs its own libxml2 and others, which I need for other software I will install, and this has caused me problems on an old machine. I am open to considering a virtualenv, but was hoping to learn to just fix my current problem if possible.
Thanks,
Andre
PS, when pip install matplotlib`, the following warning appears, which seems odd because matplotlib is such a staple piece of software
You are installing an externally hosted file. Future versions of pip will default to disallowing externally hosted files.
You are installing a potentially insecure and unverifiable file. Future versions of pip will default to disallowing insecure files.
This is an issue in pygtk. You can test it with brew (it should throw the same error):
brew test pygtk
I ran into the same problem, and got past that error with the following steps from https://github.com/mxcl/homebrew/issues/13654
brew rm py2cairo
brew install py2cairo
You can test that pygtk is working using brew test pygtk again.
I'm still having other problems getting pip install matplotlib to work, so you may also run into more problems, but that should get you past that particular issue.
I had the same problem, and after some experimentation it seems that installing under Python 3 works more reliably. i.e. this installed without error:
pip3 install matplotlib
I then had to re-install everything else using pip3, and make sure I was running under python3 at execution time.
brew install freetype
it works on mac os sierra!