Brownie Import Error: _PyGen_Send [Ubuntu Jelly 22.04] - python

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

Related

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

I have installed opencv-python using command pip, but am facing importError while executing import cv2 on aws

I have installed Opencv on AWS ec2-instance using pip3 install opencv-python but while importing cv2 it throws an error
import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib64/python3.7/site-packages/cv2/__init__.py", line 5, in
<module>
from .cv2 import *
ImportError: libSM.so.6: cannot open shared object file: No such file or
directory`
I have also tried to download some modules using below command to solve the issue but it also not working
sudo yum install -y libsm6 libxext6 libxrender-dev`
sudo yum install libXtst

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

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.

Ubuntu 16.04 pip seems broken

I was installing some packages, after that pip doesn't work anymore. Even if I try some command such as: sudo pip show requets I get this error.
Traceback (most recent call last):
File "/usr/local/bin/pip", line 7, in <module>
from pip import main
File "/usr/local/lib/python3.5/dist-packages/pip/__init__.py", line 28, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/local/lib/python3.5/dist-packages/pip/vcs/subversion.py", line 9, in <module>
from pip.index import Link
File "/usr/local/lib/python3.5/dist-packages/pip/index.py", line 31, in <module>
from pip.wheel import Wheel, wheel_ext
File "/usr/local/lib/python3.5/dist-packages/pip/wheel.py", line 6, in <module>
import compileall
File "/usr/lib/python3.5/compileall.py", line 20, in <module>
from concurrent.futures import ProcessPoolExecutor
File "/usr/local/lib/python3.5/dist-packages/futures-3.1.1-py3.5.egg/concurrent/futures/__init__.py", line 8, in <module>
from concurrent.futures._base import (FIRST_COMPLETED,
File "/usr/local/lib/python3.5/dist-packages/futures-3.1.1-py3.5.egg/concurrent/futures/_base.py", line 381
raise exception_type, self._exception, self._traceback
^
SyntaxError: invalid syntax
Thanks anyways!
You seem to have installed the futures package on python3.5.
That is a python2 only backport of a python3.2+ package.
You need to delete /usr/local/lib/python3.5/dist-packages/futures-3.1.1-py3.5.egg then it should work again.
You don't need that package on python3.5, it is already included in the standard library.
You should try reinstalling pip if nothing else is working for you. Execute the following:
sudo apt-get install --reinstall python2.7
sudo apt-get purge python-pip
wget https://raw.github.com/pypa/pip/master/contrib/get-pip.py
sudo python get-pip.py
That should work. After doing that, run pip --version and please post the results.
Looks like your pip is broken, can you check pip version using pip --version and maybe upgrading pip to latest version might solve your problem, just try
sudo pip install --upgrade pip , now check pip version and if it still shows the old version try to recreate the simlink using ln -s /usr/local/bin/pip /usr/bin/

ImportError when importing Basemap

I have problems importing basemap, even though I just installed it via pip install basemap. I've tried both with python2.7 and python3:
python3
>>> from mpl_toolkits.basemap import Basemap
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'mpl_toolkits'
python2.7
>>> from mpl_toolkits.basemap import Basemap
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/mpl_toolkits/basemap/__init__.py", line 37, in <module>
import _geoslib
ImportError: libgeos_c.so.1: cannot open shared object file: No such file or directory
I'm on a ubuntu OS.
What worked for me on ubuntu:
sudo apt-get install libgeos-3.4.2
sudo apt-get install libgeos-dev
sudo pip install https://github.com/matplotlib/basemap/archive/master.zip
It worked for me in python3 with v3.1.2 of matplotlib:
sudo apt-get update -y
sudo apt-get install -y python3-mpltoolkits.basemap
Check matplotlib module version running in python:
>>>import matplotlib
>>>matplotlib.__version__
'3.1.2'
Upgrade module:
sudo pip3 install matplotlib --upgrade

Categories