You are not logged in.
When opening a python kernel in jupyter, it crashes.
This happened after removing all packages installed with pip, to install them with pacman.
I tried removing anything i could and reinstall python using
$ sudo python -S jupyter
$ python -c 'import prompt_toolkit.eventloop; print(prompt_toolkit.eventloop.__file__)'
still returns:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python3.7/site-packages/prompt_toolkit/__init__.py", line 16, in <module>
from .interface import CommandLineInterface
File "/usr/lib/python3.7/site-packages/prompt_toolkit/interface.py", line 19, in <module>
from .application import Application, AbortAction
File "/usr/lib/python3.7/site-packages/prompt_toolkit/application/__init__.py", line 2, in <module>
from .application import Application
File "/usr/lib/python3.7/site-packages/prompt_toolkit/application/application.py", line 3, in <module>
from prompt_toolkit.buffer import Buffer
File "/usr/lib/python3.7/site-packages/prompt_toolkit/buffer.py", line 9, in <module>
from .completion import Completer, Completion, CompleteEvent
File "/usr/lib/python3.7/site-packages/prompt_toolkit/completion/__init__.py", line 2, in <module>
from .base import Completion, Completer, ThreadedCompleter, DummyCompleter, DynamicCompleter, CompleteEvent, merge_completers, get_common_complete_suffix
File "/usr/lib/python3.7/site-packages/prompt_toolkit/completion/base.py", line 4, in <module>
from prompt_toolkit.eventloop import generator_to_async_generator, AsyncGeneratorItem
ImportError: cannot import name 'generator_to_async_generator' from 'prompt_toolkit.eventloop' (/usr/lib/python3.7/site-packages/prompt_toolkit/eventloop/__init__.py)
Last edited by thund3rpantz (2018-11-06 16:34:34)
Offline
I tried removing anything i could and reinstall python using
$ sudo python -S jupyter
Probably you meant reinstalling the package with pacman?
$ sudo pacman -S jupyter$ python -c 'import prompt_toolkit.eventloop; print(prompt_toolkit.eventloop.__file__)'
still returns:
....
File "/usr/lib/python3.7/site-packages/prompt_toolkit/completion/base.py", line 4, in <module>
from prompt_toolkit.eventloop import generator_to_async_generator, AsyncGeneratorItem
ImportError: cannot import name 'generator_to_async_generator' from 'prompt_toolkit.eventloop' (/usr/lib/python3.7/site-packages/prompt_toolkit/eventloop/__init__.py)
That file `prompt_toolkit/completion/base.py` doesn't exist in the community package python-prompt_toolkit 1.0.15-2. It seems you have installed a version 2.0.x, e.g. from AUR.
Jupyter notebook and prompt_toolkit works fine for me with the community packages.
Last edited by spinnau (2018-11-06 09:52:27)
Offline
Hmm. my installed prompt_toolkit it also version 1.0.15-2, as i installed it together with python and the jupyter package.
Why is is tried imported?
But you are right, I had promt_toolkit-2.0.6.dist-info in /usr/lib/python3.7/site-packages. most likely installed using pip.
So i have learned the hard way why not use pip outside a virtual environment.
Removing the folder did not change anything.
What is the best way to remove all installed python packages and start from scratch?
Offline
Might not be the safest way, so be careful if anyone is doing the same thing:
sudo pacman -Rsc python python2 !!!! Be careful, this might remove much more than wanted!
sudo rm -rf /usr/lib/python*
pacman -Syu python jupyter-notebook
This approach worked, but I feel dirty.
I'm only going installing python packages with pacman from now on.
Thanks for the help!
Offline
To remove files from the system folders that you have installed without pacman please see https://wiki.archlinux.org/index.php/Pa … ny_package
If you want to install packages with pip e.g. because there is no official arch package for that or you want a newer version of that python package, then you can install it as user. The package will then be installed to ~/.local/lib/python3.7/site-packages. You can also safely delete unwanted packages there without breaking your system.
$ pip install package-name --userIf the package should be installed system wide, then creating a PKGBUILD should be preferred over letting pip copy the files to your system. Maybe someone already created an AUR package for that ;-)
Offline
Thanks for the tip!
Offline