Uninstalled wrapt module: Python not working - python

I was having difficulty installing a package because of a ModuleNotFoundError for wrapt and so I removed and tried to reinstall wrapt.
I ran the uninstall once, and wrapt was removed from one location. I tried to install, but the requirement was already satisfied, so I uninstalled wrapt again. See the three commands below:
Found existing installation: wrapt 1.12.1
Uninstalling wrapt-1.12.1:
Would remove:
c:\users\me\appdata\roaming\python\python38\site-packages\wrapt-1.12.1-py3.8.egg-info
c:\users\me\appdata\roaming\python\python38\site-packages\wrapt\*
Proceed (y/n)? y
Successfully uninstalled wrapt-1.12.1
PS C:\Users\me> pip install wrapt
Requirement already satisfied: wrapt in c:\users\me\appdata\local\programs\python\python38\lib\site-packages (1.12.1)
PS C:\Users\me> pip uninstall wrapt
Found existing installation: wrapt 1.12.1
Uninstalling wrapt-1.12.1:
Would remove:
c:\users\me\appdata\local\programs\python\python38\lib\site-packages\wrapt-1.12.1.dist-info\*
c:\users\me\appdata\local\programs\python\python38\lib\site-packages\wrapt\*
Proceed (y/n)? y
Successfully uninstalled wrapt-1.12.1
I thought I was all ready to start with a clean slate, but no such luck. Now I receive the following error whenever I try to run python or pip.
Fatal Python error: init_import_size: Failed to import the site module
Python runtime state: initialized
Traceback (most recent call last):
File "c:\users\me\appdata\local\programs\python\python38\lib\site.py", line 580, in <module>
main()
File "c:\users\me\appdata\local\programs\python\python38\lib\site.py", line 575, in main
execusercustomize()
File "c:\users\me\appdata\local\programs\python\python38\lib\site-packages\certifi_win32\bootstrap.py", line 45, in _execusercustomize
_register_bootstrap_functions()
File "c:\users\me\appdata\local\programs\python\python38\lib\site-packages\certifi_win32\bootstrap.py", line 25, in _register_bootstrap_functions
from . import wrapt_certifi
File "c:\users\me\appdata\local\programs\python\python38\lib\site-packages\certifi_win32\wrapt_certifi.py", line 3, in <module>
import wrapt
ModuleNotFoundError: No module named 'wrapt'
I've tried finding installation for wrapt that does not use pip, but I haven't been successful. I also attempted upgrading Python from 3.8.1 to 3.8.3, which resulted in the same ModuleNotFoundError. Uninstalling Python and installing again yielded the same result. I currently cannot use my manually installed Python or pip at all.
What would you recommend?

The solution was to use a second installation of Python (Anaconda) to fix my broken Python. My Anaconda Python maintains a separate set of installed packages, so it was still working. I opened an Anaconda prompt and ran (reference):
pip install --target="c:\users\me\appdata\local\programs\python\python38\lib\site-packages" wrapt
This reinstalled wrapt in the correct site-packages folder. My original Python is now working.
Lesson learned: be careful with pip uninstall

Related

synology NAS, pip issue, python libraries

I recently acquired a NAS and trying to run a python script. Issue is that I cannot run the python script as a normal user (python script.py). Python is only running if I run as a sudo user (e.g., sudo python script.py)
When I run as a normal user, it does not detect the libraries such as pandas. But I do not want to run as a sudo because sudo would required a password.
I think the issue comes from the pip installation.
Do you know what could be the issue?
Greatly appreciate
In the terminal, when I run "pip list" as a normal user, it states 'ModuleNotFoundError: No module named 'pip._internal'
`
user#NAS:~$ pip list
Traceback (most recent call last):
File "/bin/pip", line 5, in <module>
from pip._internal.cli.main import main
ModuleNotFoundError: No module named 'pip._internal'
but when I run as a sudo:
user#NAS:~$ sudo pip list
Password:
Package Version
certifi 2022.6.15
charset-normalizer 2.1.1
idna 3.3
numpy 1.23.2
pandas 1.5.1
pip 22.3.1
pyasn1 0.4.5
pysmb 1.2.2
python-dateutil 2.8.2
pytz 2022.2.1
requests 2.28.1
setuptools 56.0.0
six 1.16.0
thread6 0.2.0
urllib3 1.26.12
wheel 0.38.4

ModuleNotFoundError: No module named 'keyboard, tried pip3 install, tried -pip list it is there

Some extra info:
I am on Windows 10, using latest Python version, using latest pip version, using Pycharm as my IDE. I am making a keylogger program for a project and I cannot seem to get keyboard module working.
Also:
C:\Users\Hp>pip --version
pip 20.2.2 from c:\users\hp\appdata\local\programs\python\python38-32\lib\site-packages\pip (python 3.8)
C:\Users\Hp>pip install keyboard
Requirement already satisfied: keyboard in c:\users\hp\appdata\local\programs\python\python38-32\lib\site-packages (0.13.5)
C:\Users\Hp>pip list
Package Version
altgraph 0.17
future 0.18.2
keyboard 0.13.5
pefile 2019.4.18
pip 20.2.2
PyInstaller 3.6
pywin32-ctypes 0.2.0
setuptools 41.2.0
The error message in PyCharm: C:\Users\Hp\Desktop\keylogger\venv\Scripts\python.exe C:/Users/Hp/AppData/Roaming/JetBrains/PyCharmCE2020.1/scratches/keylog.py
Traceback (most recent call last):
File "C:/Users/Hp/AppData/Roaming/JetBrains/PyCharmCE2020.1/scratches/keylog.py", line 2, in
import keyboard
ModuleNotFoundError: No module named 'keyboard'
Activate your virtual-environment
.\env\Scripts\activate
or
C:\Users\Hp\Desktop\keylogger\venv\Scripts\activate
Now install keyboard
pip install keyboard
#yedpodtrzitko already answered, I just want to make it clearer with solution-steps.

Error when upgrading Spyder to 4.0.1: ModuleNotFoundError: No module named 'IPython.core.inputtransformer2'

I recently upgraded to Spyder 4.0.1 through Anaconda via conda update spyder. Now, when I try to boot up Spyder via Anaconda Navigator, the program automatically crashes with the following dump:
Traceback (most recent call last):
File "/Users/ed/anaconda/lib/python3.6/site-packages/spyder/app/mainwindow.py", line 3718, in main
mainwindow = run_spyder(app, options, args)
File "/Users/ed/anaconda/lib/python3.6/site-packages/spyder/app/mainwindow.py", line 3559, in run_spyder
main.setup()
File "/Users/ed/anaconda/lib/python3.6/site-packages/spyder/app/mainwindow.py", line 1010, in setup
from spyder.plugins.ipythonconsole.plugin import IPythonConsole
File "/Users/ed/anaconda/lib/python3.6/site-packages/spyder/plugins/ipythonconsole/plugin.py", line 52, in
from spyder.plugins.ipythonconsole.widgets import ClientWidget
File "/Users/ed/anaconda/lib/python3.6/site-packages/spyder/plugins/ipythonconsole/widgets/__init__.py", line 16, in
from .debugging import DebuggingWidget
File "/Users/ed/anaconda/lib/python3.6/site-packages/spyder/plugins/ipythonconsole/widgets/debugging.py", line 22, in
from IPython.core.inputtransformer2 import TransformerManager
ModuleNotFoundError: No module named 'IPython.core.inputtransformer2'
I couldn't find anybody with a similar error. I updated IPython, as someone suggested, but it did not resolve the problem. Any ideas?
... since none of this worked for me, here how I solved it:
check what IPython version you have via conda list
in my case i got a rather old version 5.8.0 instead of the most recent one
(at the time of writing 7.19.0... check available versions via conda search ipython)
since conda update ipython did not provide the most recent version, i decided
to manually run the command that installs the most recent version
(for me this was conda install -c conda-forge ipython=7.19.0)
that's it...
I had the same problem. Upgrading IPython via the following command line helped resolve the situation.
sudo conda update IPython -n xxx
where xxx is the name of the environment I was trying to run Spyder in.
I had this very same issue on Spyder 4.1.4. Turns out that not all the required packages were installed correctly when I installed Spyder.
I used the following in python to test IPython:
import IPython
print(IPython.__version__)
Turned out that I had 6.4.0 so I ran the following from the terminal:
!pip install --upgrade IPython
IPython 7.16.1 was installed with prompt_toolkit-3.0.5. I also got the following errors:
ERROR: spyder 4.1.4 requires pyqt5<5.13; python_version >= "3", which is not installed.
ERROR: spyder 4.1.4 requires pyqtwebengine<5.13; python_version >= "3", which is not installed.
ERROR: jupyter-console 5.2.0 has requirement prompt-toolkit<2.0.0,>=1.0.0, but you'll have prompt-toolkit 3.0.5 which is incompatible.
ERROR: spyder 4.1.4 has requirement jedi==0.17.1, but you'll have jedi 0.12.1 which is incompatible.
ERROR: spyder 4.1.4 has requirement parso==0.7.0, but you'll have parso 0.3.0 which is incompatible.
ERROR: spyder 4.1.4 has requirement qtconsole>=4.6.0, but you'll have qtconsole 4.3.1 which is incompatible.
ERROR: spyder-kernels 1.9.2 has requirement ipykernel>=5.1.3; python_version > "2", but you'll have ipykernel 4.8.2 which is incompatible.
ERROR: spyder-kernels 1.9.2 has requirement jupyter-client>=5.3.4, but you'll have jupyter-client 5.2.3 which is incompatible.
Installing the correct versions of the above packages in pip resolved my problem.
Update to python 3.7. I had the same problem. That solved it.
conda install python=3.7 anaconda=custom
I experienced the same problem. Just do conda update IPython. All good then!

Module six not found, although module six is installed

I cannot run jupyter lab as it complains about module six. Module six is already installed with conda. I even tried to install with pip too, but it says it is already installed and doesn't do anything. So, what to do here?
jupyter lab
Traceback (most recent call last):
File "c:\users\ilyas\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\users\ilyas\anaconda3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\ilyas\Anaconda3\Scripts\jupyter-lab.EXE\__main__.py", line 5, in <module>
File "c:\users\ilyas\anaconda3\lib\site-packages\jupyterlab\labapp.py", line 11, in <module>
from jupyter_core.application import JupyterApp, base_aliases
File "c:\users\ilyas\anaconda3\lib\site-packages\jupyter_core\application.py", line 30, in <module>
from traitlets.config.application import Application, catch_config_error
File "c:\users\ilyas\anaconda3\lib\site-packages\traitlets\__init__.py", line 1, in <module>
from .traitlets import *
File "c:\users\ilyas\anaconda3\lib\site-packages\traitlets\traitlets.py", line 57, in <module>
import six
ModuleNotFoundError: No module named 'six'
I tried to remove with conda, and then re-install but that also did not work:
conda remove six
RemoveError: This operation will remove conda without replacing it with
another version of conda.
Install with pip:
pip install six
Requirement already satisfied: six in c:\users\ilyas\anaconda3\lib\site-packages (1.12.0)
python -m pip install six
Requirement already satisfied: six in c:\users\ilyas\anaconda3\lib\site-packages (1.12.0)
Environment:
Windows 10
python 3.7
jupyter-lab 1.0.0a3
six 1.12.0
you are installing six for Python 2, but trying to use it from Python 3.
install for Python 3 with:
python3 -m pip install six
Tried the following but still NOT solved:
I had to do this in the following error:
pip uninstall six
pip install six
Then I get the the ModuleNotFoundError: No module named 'jupyter_server' error.
So I install jupyter_server with conda, and now the jupyter lab is working.
conda install -c conda-forge jupyter_server
Even though the notebook is opening, I could not import packages. Checking the command prompt was showing the jupyterlab-manager was outdated. So, did the following:
jupyter labextension install #jupyter-widgets/jupyterlab-manager
Still, the notebook opens but cannot do anything with it.
few years late but I had the same problem. To add a little to what Corey was saying. I think you need to install it via Conda to use it in Conda (and hence Jupyter), i.e.
conda install six

Trouble with ipython notebook after upgrading ubuntu to 17.10

I recently upgraded ubuntu from 16.04 to 17.10.
Afterwards, when I try
sudo pip install jupyter
graphlab-create 2.1 has requirement decorator==4.0.9, but you'll have decorator 4.3.0 which is incompatible.
graphlab-create 2.1 has requirement requests==2.9.1, but you'll have requests 2.18.1 which is incompatible.
Cannot uninstall 'pyzmq'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
When I try running
ipython notebook
File "/usr/local/lib/python2.7/dist-packages/traitlets/config/application.py", line 445, in initialize_subcommand
subapp = import_item(subapp)
File "/usr/local/lib/python2.7/dist-packages/ipython_genutils/importstring.py", line 31, in import_item
module = __import__(package, fromlist=[obj])
ImportError: No module named notebook.notebookapp
Create a separate virtualenv and install Jupyter there. If you still face the same error, downgrade pip. I am assuming you are having pip version 10. You can downgrade by doing pip install pip==9.0.1. Try installing Jupyter now.
If you don't want to downgrade pip, you have to manually remove all those packages, pyzmq in this case, from site-packages directory before installing Jupyter.
Reference: https://github.com/pypa/pip/issues/5247

Categories