Spyder3 not launching - How to launch? [duplicate] - python

Since updating my python3 packages via python3-pip on Ubuntu 18.04.2 LTS I am unable to launch spyder as it appears that the QtWebKitWidgets module of the PyQt5 package has been deprecated. The following console output is produced upon entering spyder3 in the terminal:
Traceback (most recent call last):
File "/home/benjamin/.local/lib/python3.6/site-packages/qtpy/QtWebEngineWidgets.py", line 22, in <module>
from PyQt5.QtWebEngineWidgets import QWebEnginePage
ModuleNotFoundError: No module named 'PyQt5.QtWebEngineWidgets'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/benjamin/.local/bin/spyder3", line 11, in <module>
sys.exit(main())
File "/home/benjamin/.local/lib/python3.6/site-packages/spyder/app/start.py", line 178, in main
from spyder.app import mainwindow
File "/home/benjamin/.local/lib/python3.6/site-packages/spyder/app/mainwindow.py", line 90, in <module>
from qtpy import QtWebEngineWidgets # analysis:ignore
File "/home/benjamin/.local/lib/python3.6/site-packages/qtpy/QtWebEngineWidgets.py", line 26, in <module>
from PyQt5.QtWebKitWidgets import QWebPage as QWebEnginePage
ModuleNotFoundError: No module named 'PyQt5.QtWebKitWidgets'
Has anyone else stumbled across this problem, and could anyone suggest a solution?
I currently update my python3 packages via the following shell script:
#!/bin/sh
#================================#
# #
#### UPDATE PYTHON3 LIBRARIES ####
# #
#================================#
### Package List ###
# bs4 - web scraping
# keras - machine learning front end
# lifelines - survival analysis
# matplotlib - plots
# numpy - array-processing package
# pandas - data management
# scipy - open-source software for mathematics, science, and engineering
# seaborn - plots
# selenium - web scraping
# spyder - IDE
# statsmodels - basic statistical methods
# tensorflow - machine learning back end
PACKAGES='bs4 keras lifelines matplotlib numpy pandas scipy seaborn selenium spyder statsmodels tensorflow'
### Update via PIP3 ###
echo 'Updating packages ...'
pip3 install $PACKAGES --user --upgrade --upgrade-strategy="eager"
echo 'Update complete ...'
... and launch spyder using the following Gnome applications launcher link, located in ~/.local/share/applications:
[Desktop Entry]
Type=Application
Version=1.0
Name=Spyder3
GenericName=Spyder3
Comment=The Scientific Python Development Environment - Python 3
Icon=spyder3
TryExec=spyder3
Exec=spyder3 %F
Terminal=false
MimeType=text/x-python;
Categories=Development;Science;IDE;Qt;
Keywords=Development;Science;IDE;Qt;
StartupNotify=true
StartupWMClass=Spyder

(Spyder maintainer here) To fix this problem you also need to install pyqtwebengine (besides pyqt5), like this
pip install pyqtwebengine
Note: We realized WebEngine was separated from PyQt5 only after we released our last version (3.3.3). But that's going to be fixed in our next one (3.3.4), to be released in March/2019.

Related

Spyder does not open from anaconda

Recently, I had to reinstall anaconda on a new computer.
I downloaded the latest version from anaconda's website, and installed it just as I did before.
Now, when I open anaconda interface and try to run Spyder.exe, I get this message:
Traceback (most recent call last):
File "C:\Users\aabramzonx0108132\AppData\Local\Continuum\anaconda3\lib\site-packages\qtpy\QtWebEngineWidgets.py", line 22, in
from PyQt5.QtWebEngineWidgets import QWebEnginePage
ImportError: DLL load failed: The specified procedure could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\aabramzonx0108132\AppData\Local\Continuum\anaconda3\Scripts\spyder-script.py", line
10, in
sys.exit(main())
File "C:\Users\aabramzonx0108132\AppData\Local\Continuum\anaconda3\lib\site-
packages\spyder\app\start.py", line 186, in main
from spyder.app import mainwindow
File "C:\Users\aabramzonx0108132\AppData\Local\Continuum\anaconda3\lib\site-
packages\spyder\app\mainwindow.py", line 90, in
from qtpy import QtWebEngineWidgets # analysis:ignore
File "C:\Users\aabramzonx0108132\AppData\Local\Continuum\anaconda3\lib\site-
packages\qtpy\QtWebEngineWidgets.py", line 26, in
from PyQt5.QtWebKitWidgets import QWebPage as QWebEnginePage
ModuleNotFoundError: No module named 'PyQt5.QtWebKitWidgets'
Could it be that I installed something wrong?
This has to do with PyQt5 module. To fix this issue try removing PyQt5
pip uninstall PyQt5
If that does not work try to reinstall it using
conda install -f qt=5 pyqt=5
Similar post here: 54869374
Anaconda 2020.07, Linux, x84_64
I do not know why, but installing
pip install pyqtwebengine
fixed spyder, which was part of the Anaconda installation.
Details:
This was tested on a fresh fedora-33 virtual machine with Anaconda version Anaconda3-2020.07-Linux-x86_64. pyqtwebengine was not installed before. Trying to uninstall it, gave a WARNING: Skipping pyqtwebengine as it is not installed.

Cannot run Spyder because No module named 'PySide'

I wanted to try using Spyder IDE. I was reading this page on how to open and run Spyder: https://github.com/spyder-ide/spyder/releases
I typed the following commands as specified in the page:
conda update qt pyqt
conda update spyder
Both commands gave "# All requested packages already installed.".
I then typed spyder into my terminal (Mac):
Macs-MacBook:~ macuser$ spyder
Traceback (most recent call last):
File "/anaconda3/lib/python3.6/site-packages/qtpy/__init__.py", line 166, in <module>
from PySide import __version__ as PYSIDE_VERSION # analysis:ignore
ModuleNotFoundError: No module named 'PySide'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/anaconda3/bin/spyder", line 11, in <module>
sys.exit(main())
File "/anaconda3/lib/python3.6/site-packages/spyder/app/start.py", line 159, in main
from spyder.app import mainwindow
File "/anaconda3/lib/python3.6/site-packages/spyder/app/mainwindow.py", line 49, in <module>
So, I tried to install PySide:
Macs-MacBook:~ macuser$ conda install PySide
Solving environment: failed
UnsatisfiableError: The following specifications were found to be in conflict:
- anaconda==5.2.0=py36_3
- pyside
Use "conda info <package>" to see the dependencies for each package.
What should I do to get up and running with Spyder?
try below commands let me know if it works.
pip install msgpack
conda install qt=5.6 pyqt=5.6 sip=4.18
While other solutions found on the web didn't work for me (such as the one above and using $ pip install pyqt5), I solved this by uninstalling and reinstalling Spyder via terminal, using pip.
$ pip uninstall spyder
...
$ pip install spyder
...
Not sure why, but it worked on the first try.
Mr J.
I had the same problem as Doug Fir. I used these commands. I launched spyder from the DOS prompt. I got "RuntimeError: module compiled against API version 0xb but this version of numpy is 0xa" as was the case before. Just as I was rolling my eyes, Spyder went ahead and started. So I think it worked.
Try to delete the .condarc file. I do not know the specific reason but I faced the same issue and when I deleted the .condarc file it worked for me.
I had same error on Linux and solved deleting:
rm -rf .local/lib/python3.9/
rm -rf .local/share/Spyder/

Install labelme annotation tools

I tried to install labelme annotation tools on Mac os 10.11.x from this link labelme using the virtual environment method listed below:
# python3
conda create --name=labelme python=3.6
source activate labelme
# conda install pyqt
pip3 install pyqt5 # pyqt5 can be installed via pip on python3
pip3 install labelme
When I run labelme on terminal I get this error:
File "/Users/xxx/anaconda3/lib/python3.6/site-packages/labelme/app.py", line 32, in <module>
from PyQt5.QtGui import *
ImportError: dlopen(/usr/local/lib/python2.7/site-packages/PyQt5/QtGui.so, 2):
Symbol not found: _PyInt_AsLong
Referenced from: /usr/local/lib/python2.7/site-packages/PyQt5/QtGui.so
Expected in: flat namespace in /usr/local/lib/python2.7/site-packages/PyQt5/QtGui.so
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/xxxx/anaconda3/bin/labelme", line 7, in <module>
from labelme.app import main
File "/Users/rafikgouiaa/anaconda3/lib/python3.6/site-packages/labelme/app.py", line 37, in <module>
from PyQt4.QtGui import *
ModuleNotFoundError: No module named 'PyQt4'**
It seems that labelme looks for pyqt5 in Python 2.7, not in Python 3.6 where pyqt5 is installed.
Any help for installing labelme or any other tools other than labelme and Matlab tools?

Python 2.7: Import Error for 'matplotlib' and 'plotly' (OS X)

I am trying to import matplotlib and plotly in my python script to plot a simple distribution. Earlier when I was running the script, it was displaying nothing on the command-line and it seemed that it was simply processing the import statement.
To debug it, I upgraded python using brew install python after that and did a pip install --upgrade pip after that. Using the upgraded pip, I made sure that matplotlib and plotly are installed. But, upon running the script, I am getting the following error on command-line:
$ python script.py
Traceback (most recent call last):
File "script.py", line 5, in <module>
import matplotlib.pyplot as plt
File "/usr/local/lib/python2.7/site-packages/matplotlib/__init__.py", line 110, in <module>
import io
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/io.py", line 51, in <module>
import _io
ImportError: dlopen(/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyCodecInfo_GetIncrementalDecoder
Referenced from: /usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so
Expected in: flat namespace
in /usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so
Can someone please help me resolve this issue?
Thanks in advance.
I found a similar SO issue for Selenium. The problem appeared to be a python issue after updating and the solution there was to type hash -r python in the terminal. Worth a try.

Gtk* backend requires pygtk to be installed

From within a virtual environment, trying to load a script which uses matplotlib's GTKAgg backend, I fail with the following traceback:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/user/.virtualenvs/venv/local/lib/python2.7/site-packages/matplotlib/pyplot.py", line 97, in <module>
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "/home/user/.virtualenvs/venv/local/lib/python2.7/site-packages/matplotlib/backends/__init__.py", line 25, in pylab_setup
globals(),locals(),[backend_name])
File "/home/user/.virtualenvs/venv/local/lib/python2.7/site-packages/matplotlib/backends/backend_gtkagg.py", line 10, in <module>
from matplotlib.backends.backend_gtk import gtk, FigureManagerGTK, FigureCanvasGTK,\
File "/home/user/.virtualenvs/venv/local/lib/python2.7/site-packages/matplotlib/backends/backend_gtk.py", line 16, in <module>
raise ImportError("Gtk* backend requires pygtk to be installed.")
ImportError: Gtk* backend requires pygtk to be installed.
The code which I ran in order to produce that ImportError is as follows:
import matplotlib as mpl
mpl.use('GTKAgg')
import matplotlib.pyplot as plt
When running the very same code after deactivating my virtual environment, everything goes well.
I assumed this may be due to version differences; indeed, such differences exist on my machine. However, the version in the virtual environment is newer (1.2.0 versus 1.1.1rc), so I am not expecting less support.
In case it is not clear: my question is how to allow importing pyplot with GTKAgg backend on a new version of matplotlib, or at least an attempt to understand the reasons for this import failure.
You probably created your virtual evn by something like:
$ virtualenv ~/.virtualenvs/my_env
by default this can see none of your system-installed packages (including pygtk) so when you try to run mpl it rightly complains that you do not have pygtk installed because (with in the context of the virtualenv) you do not.
You can either build and install pygtk within your virtualenv or you can use
$ virtualenv --system-site-packages ~/.virtualenvs/my_env
(doc) which will make your virtualenv inherit from your global packages.
I'm not sure if you're on Ubuntu, but to solve this I had to install matplotlib from source to get this to work. The key instructions (from http://www.pyimagesearch.com/2015/08/24/resolved-matplotlib-figures-not-showing-up-or-displaying/) are:
$ workon plotting
$ pip uninstall matplotlib
$ git clone https://github.com/matplotlib/matplotlib.git
$ cd matplotlib
$ python setup.py install
Changing backends and using --system-site-packages didn't work for me.

Categories