spyder3: "ModuleNotFoundError: No module named 'simplegeneric'" - python

I upgraded my Ubuntu 16.04 to 18.04. Then I created a new virtual environment for Python and started spyder3:
python3 -m venv dev
source dev/bin/activate
spyder3
Then I got an error:
...
ModuleNotFoundError: No module named 'simplegeneric'
So I had to do:
pip install wheel
pip install simplegeneric
But spyder3 still says that there is no module named 'simplegeneric'. Why?
Some information about versions and installed modules:
(dev) /media/shared/Development/python$ python3 -V
Python 3.6.5
(dev) /media/shared/Development/python$ pip -V
pip 9.0.1 from /media/shared/Development/python/dev/lib/python3.6/site-packages (python 3.6)
(dev) /media/shared/Development/python$ which spyder3
/media/shared/Development/python/dev/bin/spyder3
(dev) /media/shared/Development/python$ which pip
/media/shared/Development/python/dev/bin/pip
(dev) /media/shared/Development/python$ pip freeze | grep simplegeneric
simplegeneric==0.8.1
EDIT:
My problem is not that I can't import simplegeneric within spyder. My problem is that I cannot open spyder:
(dev) /media/shared/Development/python$ spyder3
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/spyder/app/mainwindow.py", line 3126, in main
mainwindow = run_spyder(app, options, args)
File "/usr/lib/python3/dist-packages/spyder/app/mainwindow.py", line 3023, in run_spyder
main.setup()
File "/usr/lib/python3/dist-packages/spyder/app/mainwindow.py", line 932, in setup
from spyder.plugins.ipythonconsole import IPythonConsole
File "/usr/lib/python3/dist-packages/spyder/plugins/ipythonconsole.py", line 59, in <module>
from spyder.widgets.ipythonconsole import ClientWidget
File "/usr/lib/python3/dist-packages/spyder/widgets/ipythonconsole/__init__.py", line 12, in <module>
from .debugging import DebuggingWidget
File "/usr/lib/python3/dist-packages/spyder/widgets/ipythonconsole/debugging.py", line 16, in <module>
from qtconsole.rich_jupyter_widget import RichJupyterWidget
File "/usr/lib/python3/dist-packages/qtconsole/rich_jupyter_widget.py", line 14, in <module>
from .jupyter_widget import JupyterWidget
File "/usr/lib/python3/dist-packages/qtconsole/jupyter_widget.py", line 19, in <module>
from IPython.lib.lexers import IPythonLexer, IPython3Lexer
File "/usr/lib/python3/dist-packages/IPython/__init__.py", line 49, in <module>
from .terminal.embed import embed
File "/usr/lib/python3/dist-packages/IPython/terminal/embed.py", line 18, in <module>
from IPython.terminal.interactiveshell import TerminalInteractiveShell
File "/usr/lib/python3/dist-packages/IPython/terminal/interactiveshell.py", line 30, in <module>
from .debugger import TerminalPdb, Pdb
File "/usr/lib/python3/dist-packages/IPython/terminal/debugger.py", line 6, in <module>
from IPython.core.completer import IPCompleter
File "/usr/lib/python3/dist-packages/IPython/core/completer.py", line 34, in <module>
from IPython.utils import generics
File "/usr/lib/python3/dist-packages/IPython/utils/generics.py", line 8, in <module>
from simplegeneric import generic
ModuleNotFoundError: No module named 'simplegeneric'
EDIT 2:
It's obvious that I have the module 'simplegeneric' installed somewhere but spyder3 can't find it. So I guess my problem is related to sys.path or $PYTHONPATH.
That's my sys.path within the dev environment:
(dev) /media/shared/Development/python$ python3 -c "import sys; print('\n'.join(sys.path))"
/usr/lib/python36.zip
/usr/lib/python3.6
/usr/lib/python3.6/lib-dynload
/media/shared/Development/python/dev/lib/python3.6/site-packages
And that's my regular sys.path:
~$ python3 -c "import sys; print('\n'.join(sys.path))"
/usr/lib/python36.zip
/usr/lib/python3.6
/usr/lib/python3.6/lib-dynload
/usr/local/lib/python3.6/dist-packages
/usr/lib/python3/dist-packages
Shouldn't sys.path of my dev environment contain everything from the regular sys.path?

I tried this, but it worked fine for me.
C:\Users\RayanMadrid>pip install simplegeneric
Collecting simplegeneric
Downloading
https://files.pythonhosted.org/packages/3d/57/4d9c9e3ae9a255cd4e106bb57e24056d3d0709fc01b2e3e345898e49d5b/simplegeneric-0.8.1.zip
Installing collected packages: simplegeneric
Running setup.py install for simplegeneric ... done
Successfully installed simplegeneric-0.8.1
Then I ran it in Python:
>>> import simplegeneric
>>>
So your problem is something local to your machine.

OK, finally I could solve my problem:
pip3 was linked to a local copy and I think my local pip3 was messed up:
~$ which pip3
/usr/local/bin/pip3
So I did:
~$ sudo mv /usr/local/bin/pip3 pip3_bak
~$ which pip3
/usr/bin/pip3
Then I had to reinstall python3-simplegeneric:
~$ sudo apt-get install python3-simplegeneric --reinstall
Now I can start Spyder3 3.2.6 regularly or Spyder3 3.2.8 in my (dev) environment.

Related

Brownie Import Error: _PyGen_Send [Ubuntu Jelly 22.04]

I just updated my ubuntu os and after had installed the following:
$ python3 -m pip install --user pipx
$ python3 -m pipx ensurepath
$ pipx install eth-brownie
when i launch the brownie console i get the following message:
Traceback (most recent call last):
File "/home/user/.local/bin/brownie", line 5, in
from brownie._cli.main import main
File "/home/user/.local/pipx/venvs/eth-brownie/lib/python3.10/site-packages/brownie/init.py", line 6, in
from brownie.project import compile_source, run
File "/home/user/.local/pipx/venvs/eth-brownie/lib/python3.10/site-packages/brownie/project/init.py", line 3, in
from .main import ( # NOQA 401
File "/home/user/.local/pipx/venvs/eth-brownie/lib/python3.10/site-packages/brownie/project/main.py", line 44, in
from brownie.network import web3
File "/home/user/.local/pipx/venvs/eth-brownie/lib/python3.10/site-packages/brownie/network/init.py", line 4, in
from .account import Accounts
File "/home/user/.local/pipx/venvs/eth-brownie/lib/python3.10/site-packages/brownie/network/account.py", line 12, in
import eth_account
File "/home/user/.local/pipx/venvs/eth-brownie/lib/python3.10/site-packages/eth_account/init.py", line 1, in
from eth_account.account import ( # noqa: F401
File "/home/user/.local/pipx/venvs/eth-brownie/lib/python3.10/site-packages/eth_account/account.py", line 8, in
from cytoolz import (
File "/home/user/.local/pipx/venvs/eth-brownie/lib/python3.10/site-packages/cytoolz/init.py", line 3, in
from .functoolz import *
ImportError: /home/user/.local/pipx/venvs/eth-brownie/lib/python3.10/site-packages/cytoolz/functoolz.cpython-310-x86_64-linux-gnu.so: undefined symbol: _PyGen_Send
Distributor ID: Ubuntu
Description: Ubuntu 22.04 LTS
Release: 22.04
Codename: jammy
Can someone help me with this?
Thanks
I ended up installing python 3.8 and then ran:
pipx install --python python3.8 eth-brownie
If you get errors then you may have to run these commands before you install brownie:
sudo apt install python3.8-distutils
sudo apt-get install python3.8-dev

Pip broken after upgrade. Cannot unsinstall or upgrade Pip or Python

I recently had tried to run a pip command and noticed my pip version was considerably out of date so upgraded it. This seems to have completely broken my pip install and I cannot figure out how to reset it.
$ pip3 --version
pip 8.1.1 from /usr/lib/python3/dist-packages (python 3.5)
You are using pip version 8.1.1, however version 22.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
$ pip3 install --upgrade pip
Collecting pip
Downloading https://files.pythonhosted.org/packages/f3/77/23152f90de45957b59591c34dcb39b78194eb67d088d4f8799e9aa9726c4/pip-22.1-py3-none-any.whl (2.1MB)
100% |████████████████████████████████| 2.2MB 505kB/s
Installing collected packages: pip
Successfully installed pip-8.1.1
You are using pip version 8.1.1, however version 22.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
$ pip3 --version
Traceback (most recent call last):
File "/usr/bin/pip3", line 11, in <module>
sys.exit(main())
File "/home/myname/.local/lib/python3.5/site-packages/pip/__init__.py", line 11, in main
from pip._internal.utils.entrypoints import _wrapper
File "/home/myname/.local/lib/python3.5/site-packages/pip/_internal/utils/entrypoints.py", line 12
f"pip{sys.version_info.major}",
^
SyntaxError: invalid syntax
This seems to come from this: https://github.com/pypa/pip/issues/9526
I can't seem to uninstall pip:
$ python3 -m pip uninstall pip
Traceback (most recent call last):
File "/usr/lib/python3.5/runpy.py", line 184, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/myname/.local/lib/python3.5/site-packages/pip/__main__.py", line 29, in <module>
from pip._internal.cli.main import main as _main
File "/home/myname/.local/lib/python3.5/site-packages/pip/_internal/cli/main.py", line 57
sys.stderr.write(f"ERROR: {exc}")
^
SyntaxError: invalid syntax
I'm on python3.5 and can't seem to upgrade that either:
$ sudo apt-get install python3.6
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package python3.6
E: Couldn't find any package by glob 'python3.6'
E: Couldn't find any package by regex 'python3.6'
I'm found a number of stackoverflow answers suggesting to use alternative repositories but they're not working either.
$ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt-get update
$ sudo apt-get install python3.6
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package python3.6
E: Couldn't find any package by glob 'python3.6'
E: Couldn't find any package by regex 'python3.6'
I've tried 3.6, 3.7, 3.8, 3.9 and 3.10 with the same results.
I've also found some stack overflow answers suggesting to edit /usr/bin/pip3
Originally it looks like this:
from pip import main
if __name__ == '__main__':
sys.exit(main())
I've tried this:
from pip._internal import __main__
if __name__ == '__main__':
sys.exit(main())
and this:
I've tried this:
from pip._internal import __main__
if __name__ == '__main__':
sys.exit(__main__._main())
But neither have resolved the issue.
To be sure i'm not messed up with a local version i've tried all of the above using /usr/bin/pip3 --version rather than just pip3 --version with the same results.
Now i'm at a bit of a loss how to get a working version of Python and Pip.
Suggestion from question:
$ sudo python3.5 -m easy_install pip
Searching for pip
Best match: pip 22.1
Adding pip 22.1 to easy-install.pth file
Installing pip3 script to /usr/local/bin
Installing pip3.10 script to /usr/local/bin
Installing pip script to /usr/local/bin
Using /home/myname/.local/lib/python3.5/site-packages
Processing dependencies for pip
Finished processing dependencies for pip
$ ls -lh /usr/local/bin/*pip*
-rwxr-xr-x 1 root root 361 May 12 19:49 /usr/local/bin/pip
-rwxr-xr-x 1 root root 363 May 12 19:49 /usr/local/bin/pip3
-rwxr-xr-x 1 root root 369 May 12 19:49 /usr/local/bin/pip3.10
All 3 return the same thing:
$ /usr/local/bin/pip --version
$ /usr/local/bin/pip3 --version
$ /usr/local/bin/pip3.10 --version
Traceback (most recent call last):
File "/usr/local/bin/pip", line 11, in <module>
load_entry_point('pip==22.1', 'console_scripts', 'pip')()
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 561, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2631, in load_entry_point
return ep.load()
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2291, in load
return self.resolve()
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2297, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/home/myname/.local/lib/python3.5/site-packages/pip/_internal/cli/main.py", line 57
sys.stderr.write(f"ERROR: {exc}")
^
I've now installed Python3.6 using "method two" from here: https://askubuntu.com/questions/1152640/apt-install-doesnt-install-python3-6 i.e. manual install
I've then upgraded pip using:
sudo python3.6 -m pip install pip --upgrade
Now pip --version and pip3 --version return an error but directly accessing the bin works:
$ /usr/local/bin/pip --version
pip 21.3.1 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)
The aliases are currently pointing to:
$ which pip
/home/sortitoutsi/.local/bin/pip
$ which pip3
/home/sortitoutsi/.local/bin/pip3
It seems that other things are now broken, such as aws.
$ aws --help
Traceback (most recent call last):
File "/usr/local/bin/aws", line 19, in <module>
import awscli.clidriver
File "/usr/local/lib/python2.7/dist-packages/awscli/clidriver.py", line 17, in <module>
import botocore.session
File "/usr/local/lib/python2.7/dist-packages/botocore/session.py", line 29, in <module>
import botocore.configloader
File "/usr/local/lib/python2.7/dist-packages/botocore/configloader.py", line 19, in <module>
from botocore.compat import six
File "/usr/local/lib/python2.7/dist-packages/botocore/compat.py", line 26, in <module>
from dateutil.tz import tzlocal
File "/usr/local/lib/python2.7/dist-packages/dateutil/tz/__init__.py", line 1, in <module>
from .tz import *
File "/usr/local/lib/python2.7/dist-packages/dateutil/tz/tz.py", line 16, in <module>
from six import string_types, PY3
ImportError: No module named six
Simply reinstalling aws sudo python -m pip install awscli seemed to have fixed the above. I'm guessing a sudo apt-get update at some point forced an upgrade of awscli after finding an updated Python installation.
Do not try and install Python versions and packages (from another ppa) that are not supported by your OS. Your system may break.
Your attempted Pip installation is, luckily, in a local directory: $HOME/.local/. Check if there is anything else installed in $HOME/.local/bin/ and $HOME/.local/lib/python3.5/site-packages/. If nothing (or nothing that seems important), rename that directory:
mv ~/.local ~/.local_aside
Now, you should have the system Pip back again.
You may lose some other packages that you installed earlier (which would now be in ~/.local_aside, but possibly, you can reinstall those. Either with a system packages (e.g., python3-numpy), or again with pip3 install numpy and the like. Though pip may have trouble finding a correct NumPy version, since Python 3.5 is not supported anymore (the system package should be fine).
If you want to use a more recent version of Python, install a local (user-only) one. My preferred way of doing that is to use pyenv, which requires some set up (installing the necessary build packages). If you use pyenv, carefully read the installation instructions for your case. Once you get it going, you can quickly install any version of Python, and between minor versions, they won't even get in the way (that is, python3.9 -m pip install numpy will be a separate installation from python3.10 -m pip install numpy, and both can happily live next to each other if so wanted).
But don't use sudo and install it as a root: your system will get confused and may break.
Another alternative is Conda, in the form (my preference) of miniconda3. Conda can and will also install C library dependencies, and actively tries to resolve version conflicts between Python packages (in case you have to install a lot of packages). Again, browse the manual to get going, but it's relatively straightforward to use, and doesn't get in the way of your OS.

ImportError: cannot import name 'sysconfig' from 'distutils' (/usr/lib/python3.8/distutils/__init__.py)

I installed pip3 using sudo apt-get install python3-pip after that when I run the following command to install django sudo pip3 install django I get this error:
Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in
from pip import main
File "/usr/lib/python3/dist-packages/pip/init.py", line 14, in
from pip.utils import get_installed_distributions, get_prog
File "/usr/lib/python3/dist-packages/pip/utils/init.py", line 23, in
from pip.locations import (
File "/usr/lib/python3/dist-packages/pip/locations.py", line 9, in
from distutils import sysconfig
ImportError: cannot import name 'sysconfig' from 'distutils' (/usr/lib/python3.8/distutils/init.py)
How do I fix this?
I have tried recently manually installing python3.9 version in my Ubuntu from 3.6 version using apt install python3.9. Then pip3 was broken. The issue is because distutils were not build for the 3.9 version.
So in my case I ran apt install python3.9-distutils to resolve my issue.
In your case make sure to modify 3.x version in distutils command.
This helped but then I got another error: ImportError: No module named 'pip._internal'
The following fixed it:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py --force-reinstall

pip install futures breaks pip, but only on amazonlinux?

This probably falls under "don't do this" category, given https://github.com/agronholm/pythonfutures/issues/41 - it's a backport library specifically intended for use only on Python 2. But strangely, I'm seeing having it installed cause symptoms that are especially bad on Amazon Linux and not as noticeable elsewhere. Test case:
$ docker run -it amazonlinux /bin/bash
bash-4.2# yum install -y python36-virtualenv > /dev/null
bash-4.2# virtualenv-3.6 ~/testenv
Using base prefix '/usr'
New python executable in /root/testenv/bin/python3.6
Also creating executable in /root/testenv/bin/python
Installing setuptools, pip, wheel...done.
bash-4.2# source ~/testenv/bin/activate
(testenv) bash-4.2# pip --version
pip 9.0.3 from /root/testenv/local/lib/python3.6/site-packages (python 3.6)
(testenv) bash-4.2# pip install futures
Collecting futures
Downloading futures-3.1.1.tar.gz
Building wheels for collected packages: futures
Running setup.py bdist_wheel for futures ... done
Stored in directory: /root/.cache/pip/wheels/ad/79/48/b32521764d59b16fd1bc0ffd
5862f6d3bf770c7d73ea1fb12a
Successfully built futures
Installing collected packages: futures
Successfully installed futures-3.1.1
(testenv) bash-4.2# pip --version
Traceback (most recent call last):
File "/root/testenv/bin/pip", line 7, in <module>
from pip import main
File "/root/testenv/local/lib/python3.6/site-packages/pip/__init__.py", line 4
5, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/root/testenv/local/lib/python3.6/site-packages/pip/vcs/subversion.py",
line 9, in <module>
from pip.index import Link
File "/root/testenv/local/lib/python3.6/site-packages/pip/index.py", line 31,
in <module>
from pip.wheel import Wheel, wheel_ext
File "/root/testenv/local/lib/python3.6/site-packages/pip/wheel.py", line 6, i
n <module>
import compileall
File "/usr/lib64/python3.6/compileall.py", line 20, in <module>
from concurrent.futures import ProcessPoolExecutor
File "/root/testenv/local/lib/python3.6/site-packages/concurrent/futures/__ini
t__.py", line 8, in <module>
from concurrent.futures._base import (FIRST_COMPLETED,
File "/root/testenv/local/lib/python3.6/site-packages/concurrent/futures/_base
.py", line 381
raise exception_type, self._exception, self._traceback
^
SyntaxError: invalid syntax
Simply having the futures package installed on python 3 on other Linux distributions doesn't seem to cause pip to break, I haven't been able to cause the same symptom on Ubuntu or Fedora yet. What is going on inside a virtualenv on amazonlinux that causes this issue to be especially bad? If I install virtualenv via pip rather than from the amazon linux yum package python36-virtualenv, the problem doesn't manifest there either.

How to install PyWavelets for Python 3 on Kubuntu 14.04?

I'm tryting to install PyWavelets on Kubuntu 14.04, but its not working...
Since we dont have python3-pywt (we have python-pwt, for python 2) on Ubuntu oficial repositories, I tried to install it with pip, so I did:
$ sudo pip3 install pywavelets
And I've got the error:
Downloading/unpacking pywavelets
Downloading PyWavelets-0.2.2.zip (528kB): 528kB downloaded
Running setup.py (path:/tmp/pip_build_root/pywavelets/setup.py) egg_info for package pywavelets
Traceback (most recent call last):
File "", line 17, in
File "/tmp/pip_build_root/pywavelets/setup.py", line 14, in
from util import commands
File "/tmp/pip_build_root/pywavelets/util/commands.py", line 25, in
import templating
ImportError: No module named 'templating'
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 17, in
File "/tmp/pip_build_root/pywavelets/setup.py", line 14, in
from util import commands
File "/tmp/pip_build_root/pywavelets/util/commands.py", line 25, in
import templating
ImportError: No module named 'templating'
Any idea?
On Kubuntu 14.04 using Python 3.4, I installed the packages (for Python 3): python3-all-dev, and the respective ones related to numpy and Cython.
Then I clonned the sorce from the github repo pywt repo.
After that I was able to do:
$ python setup.py install --user
The build and install worked perfectly, so I tested if everythink was ok:
$ python3
>>> import pywt
>>> pywt.test()
. . .
OK (SKIP=1)
<nose.result.TextTestResult run=934 errors=0 failures=0>

Categories