Cannot run Spyder because No module named 'PySide' - python

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/

Related

Installing socketio module on python3 seems to be corrupting pip

While installing the socketio package for python using pip3 install socketio, I got the following results:
ERROR: launchpadlib 1.10.13 requires testresources, which is not installed.
WARNING: The scripts easy_install and easy_install-3.8 are installed in '/home/bill/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed netifaces-0.10.6 setuptools-3.3 socketio-0.2.1
Although I was able to import socketio successfully, pip3 seems corrupted(?).
Specifically, when trying to run anything including pip3, even pip3 by itself in the terminal, I get the same error:
Traceback (most recent call last):
File "/usr/bin/pip3", line 6, in <module>
from pkg_resources import load_entry_point
File "/home/<username>/.local/lib/python3.8/site-packages/pkg_resources.py", line 1479, in <module>
register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 144, in apport_excepthook
with os.fdopen(os.open(pr_filename,
FileNotFoundError: [Errno 2] No such file or directory: '/var/crash/_usr_bin_pip3.1000.crash'
Original exception was:
Traceback (most recent call last):
File "/usr/bin/pip3", line 6, in <module>
from pkg_resources import load_entry_point
File "/home/<username>/.local/lib/python3.8/site-packages/pkg_resources.py", line 1479, in <module>
register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'
I tried reinstalling pip3 but it didn't help. I migrated from ubuntu to mint thinking it is something buggy with the distribution but same results. I also corrupted ubuntu when I tried to remove python and reinstall it since I couldn't use pip, but, you know what they say, live and learn.
Edit: Nothing on using pip3: module "importlib._bootstrap" has no attribute "SourceFileLoader" works for me.
I am currently using linux mint 20, but I experienced the same problem on ubuntu 20.04 and 20.04.1.
Any ideas would be appreciated!
Perhaps you meant this socketio instead?: https://pypi.org/project/python-socketio
python3 -m pip install python-socketio
The package literally named "socketio" seems like it may simply be old and unsupported1, while "python-socketio" seems alive and developed 2 3
To that end, it's often valuable to take a look at similar packages and also to watch out for typosquatting et al. when installing packages via pip!
Edit: Martijn Peters makes a good point that this is the socketio you are looking for: https://pypi.org/project/python-socketio
Read on if you need a solution for the original one you posted about.
Summary: pip3 install git+https://github.com/allenmcgehee/socketio-0.2.1-patched
I was able to reproduce this in a docker container running ubuntu:20.04 exactly as you described which gave me some hope that I could help out.
I found that socketio had a dependency for setuptools==3.3 which seemed odd to me, but lines up with why the core functionality of pip was breaking after installing socketio.
I am not sure where this package is maintained as there is no git repo referenced. I did find a Russion website in the PKG-INFO, but I wasn't sure where to go from there...
Here is a version of socketio with a requirement of setuptools>=42 so that nothing gets broken: https://github.com/allenmcgehee/socketio-0.2.1-patched
And finally, here is the single command that should install socketio for you without breaking pip:
pip3 install git+https://github.com/allenmcgehee/socketio-0.2.1-patched
**I am assuming you've already fixed pip.
This happened to me with a different module. My solution was to down-grade the version of pip and the version of the module. So, for you the answer would be to run:
python -m pip install pip== (previous version of your pip)
python -m pip uninstall socketio
python -m pip install socketio==0.2.0

How to install packages in Anaconda environment in VScode?

I am running my code in VScode, my python interpreter being Anconda3\python.exe . When running the following code : -
from Ipython import display
I encounter the following error in the python terminal :
PS C:\Users\Clover\Desktop\Speech Recognition> C:/ProgramData/Anaconda3/python.exe "c:/Users/Clover/Desktop/Speech Recognition/ml_code_first.py"
Traceback (most recent call last):
File "c:/Users/Clover/Desktop/Speech Recognition/ml_code_first.py", line 11, in <module>
from Ipython import display
ModuleNotFoundError: No module named 'Ipython'
I've tried to install it on the conda terminal using :
pip install ipython
and it shows that requirement already satisfied which means the package is installed but why is this package not detected in VScode?
At least there is the warning from the conda developers: Never mix conda-forge installs and pip installs. This might help.

ModuleNotFoundError: No module named 'deeppavlov' in jupyter notebook

I've created a virtual enviornment (deepnlp) and installed the deeppavlov package in the virtual env. I could run "import deeppavlov" without any problem on the command line in the env. But when I tried to do the same thing ('import deeppavlov') in the jupyter notebook, in the kernel 'deepnlp', but I got the error mesaage:
Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'deeppavlov'
Has anyone encountered the same problem and found out the solution? This problem may or may have to do with the package 'deeppavlov'. It could be because something else.
Thanks.
As far as I know, installing a package to virtualenv has nothing to do with your Jupyter (unless the same interpreter is used in both cases). The solution would be to run the following command in jupyter cell:
import sys
!{sys.executable} -m pip install --user deeppavlov

Anaconda Navigator does not open

I have installed Anaconda (which failed a few times) and removed it again. Then installed Miniconda and after several rounds succeeded. In Terminal 'condo list'gives a result.
However, I cannot open the Anaconda Navigator.
I would like to start using Spyder. Spyder is not found in Terminal.
I checked other questions on Stack Overflow about this but nothing seems to work.
(base) 192:~ lsluyser$ sudo anaconda-navigator
Password:
Traceback (most recent call last):
File "/anaconda3/lib/python3.7/site-packages/qtpy/__init__.py", line 199, 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/anaconda-navigator", line 7, in <module>
from anaconda_navigator.app.main import main
File "/anaconda3/lib/python3.7/site-packages/anaconda_navigator/app/main.py", line 22, in <module>
from anaconda_navigator.utils.conda import is_conda_available
File "/anaconda3/lib/python3.7/site-packages/anaconda_navigator/utils/__init__.py", line 15, in <module>
from qtpy.QtGui import QIcon
File "/anaconda3/lib/python3.7/site-packages/qtpy/__init__.py", line 205, in <module>
raise PythonQtError('No Qt bindings could be found')
qtpy.PythonQtError: No Qt bindings could be found
I use a Mac Ox 10.9 and Python 3.7.
Thanks in advance for your help.
I too suffered the same multiple installation sequence as you mentioned on a Windows 10 machine.
Finally I removed a file named ".condarc" left over due to the incorrect uninstall.
The next installation of anaconda was successful in launching anaconda-navigator
but on a Mac with Homebrew installed I faced no such issues.Tip:"."Dot files are hidden on a Mac
I encountered a similar problem, I have Windows 7 installed as my OS.
Simple solution:
Uninstall Anaconda
Reinstall downloading the latest version
Before
opening the GUI, open the Conda Prompt & update all packages:
conda update --all
Now Open the GUI.
It worked for me.

Python - import error when trying to activate a virtual environment, or lauch Spyder

I get an ImportError whenever I try to activate a virtual environment, or when I try to launch Spyder.
When trying to activate a virtual environment:
Traceback (most recent call last):
File "/home/pauline/anaconda3/bin/conda", line 3, in <module>
from conda.cli import main
ImportError: No module named conda.cli
When trying to open spyder:
Traceback (most recent call last):
File "/home/pauline/anaconda3/bin/spyder", line 2, in <module>
from spyderlib import start_app
ImportError: No module named spyderlib
I tried to find an answer for that but I could mainly find problems occurring after Anaconda was just installed (mine has been installed previously and was working fine up until yesterday).
I have also tried this answer and this answer but they did not solve the problem.
The only think I can think of which may have provoked this error is that I changed the interpreter used by Spyder yesterday from the default Anaconda Python interpreter to an interpreter from a virtual environment created with virtualenv. Even then, I could close and restart Spyder with no problems, and the errors started after I rebooted my computer.
[edit] I should add that both Anaconda and my virtual environment use the same version of Python which is Python 3.5
If you are using a different python version, whatever packages that you had with anaconda or that you may have installed with conda install will not be there on the new version. You need to install them with pip or conda again.

Categories