pip broke after uninstalling a module - python

I used pip uninstall on shapely and got an exception, which I did not save.
Since then every pip or easy install command will pop this exception :
Traceback (most recent call last):
File "C:\Python27\lib\runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "C:\Python27\lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "C:\Python27\Scripts\pip.exe\__main__.py", line 5, in <module>
File "C:\Python27\lib\site-packages\pip\__init__.py", line 13, in <module>
from pip.utils import get_installed_distributions, get_prog
File "C:\Python27\lib\site-packages\pip\utils\__init__.py", line 17, in <module>
from pip.compat import console_to_str, stdlib_pkgs
File "C:\Python27\lib\site-packages\pip\compat\__init__.py", line 14, in <module>
from pip.compat.dictconfig import dictConfig as logging_dictConfig
File "C:\Python27\lib\site-packages\pip\compat\dictconfig.py", line 22, in <module>
import logging.handlers
File "C:\Python27\lib\logging\handlers.py", line 27, in <module>
import logging, socket, os, cPickle, struct, time, re
File "C:\Python27\lib\socket.py", line 47, in <module>
import _socket
ImportError: No module named _socket
Any ideas?

See this bug.
Off the top, pip uninstall shapely seems to be removing the top dlls from the Python installations. This is why you see the error on every pip command after.

Related

I'm trying to run a Python SDK and am getting errors from runpy.py. How to fix it?

(base) kiin#kiin ~ % python3 -m anki_vector.configure
Traceback (most recent call last):
File "/Users/kiin/opt/anaconda3/lib/python3.9/runpy.py", line 188, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/Users/kiin/opt/anaconda3/lib/python3.9/runpy.py", line 111, in _get_module_details
__import__(pkg_name)
File "/Users/kiin/.local/lib/python3.9/site-packages/anki_vector/__init__.py", line 22, in <module>
from . import messaging
File "/Users/kiin/.local/lib/python3.9/site-packages/anki_vector/messaging/__init__.py", line 43, in <module>
from . import client
File "/Users/kiin/.local/lib/python3.9/site-packages/anki_vector/messaging/client.py", line 23, in <module>
from .alexa_pb2_grpc import *
File "/Users/kiin/.local/lib/python3.9/site-packages/anki_vector/messaging/alexa_pb2_grpc.py", line 2, in <module>
import grpc
File "/Users/kiin/.local/lib/python3.9/site-packages/grpc/__init__.py", line 22, in <module>
from grpc import _compression
File "/Users/kiin/.local/lib/python3.9/site-packages/grpc/_compression.py", line 15, in <module>
from grpc._cython import cygrpc
ImportError: dlopen(/Users/kiin/.local/lib/python3.9/site-packages/grpc/_cython/cygrpc.cpython-39-darwin.so, 0x0002): symbol not found in flat namespace (_CFRelease)
I've tried uninstalling and reinstalling the SDK, as well as downgrade to Python 3.8. Same errors for both.

Is there any solution to error being recieved while loading jupyter-lab from cmd

UserWarning: Distutils was imported before Setuptools. This usage is discouraged and may exhibit undesirable behaviors or errors. Please use Setuptools' objects directly or at least import Setuptools first.
warnings.warn(
Traceback (most recent call last):
File "c:\users\user\appdata\local\programs\python\python39\lib\site-packages\jupyterlab_server\server.py", line 20, in
from notebook.notebookapp import aliases, flags, NotebookApp as ServerApp
File "c:\users\user\appdata\local\programs\python\python39\lib\site-packages\notebook\notebookapp.py", line 51, in
from zmq.eventloop import ioloop
File "c:\users\user\appdata\local\programs\python\python39\lib\site-packages\zmq_init_.py", line 50, in
from zmq import backend
File "c:\users\user\appdata\local\programs\python\python39\lib\site-packages\zmq\backend_init_.py", line 40, in
reraise(*exc_info)
File "c:\users\user\appdata\local\programs\python\python39\lib\site-packages\zmq\utils\sixcerpt.py", line 34, in reraise
raise value
File "c:\users\user\appdata\local\programs\python\python39\lib\site-packages\zmq\backend_init_.py", line 27, in
ns = select_backend(first)
File "c:\users\user\appdata\local\programs\python\python39\lib\site-packages\zmq\backend\select.py", line 28, in select_backend
mod = import(name, fromlist=public_api)
File "c:\users\user\appdata\local\programs\python\python39\lib\site-packages\zmq\backend\cython_init.py", line 6, in
from . import (constants, error, message, context,
ImportError: DLL load failed while importing error: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\users\user\appdata\local\programs\python\python39\lib\runpy.py", line 197, in _run_module_as_main
return run_code(code, main_globals, None,
File "c:\users\user\appdata\local\programs\python\python39\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "C:\Users\USER\AppData\Local\Programs\Python\Python39\Lib\site-packages\jupyter-lab.exe_main.py", line 4, in
File "c:\users\user\appdata\local\programs\python\python39\lib\site-packages\jupyterlab\labapp.py", line 14, in
from jupyterlab_server import slugify, WORKSPACE_EXTENSION
File "c:\users\user\appdata\local\programs\python\python39\lib\site-packages\jupyterlab_server_init.py", line 4, in
from .app import LabServerApp
File "c:\users\user\appdata\local\programs\python\python39\lib\site-packages\jupyterlab_server\app.py", line 9, in
from .server import ServerApp
File "c:\users\user\appdata\local\programs\python\python39\lib\site-packages\jupyterlab_server\server.py", line 29, in
from jupyter_server.extensions import ( # noqa
ModuleNotFoundError: No module named 'jupyter_server.extensions
It feels like you have not installed some required modules e.g. jupyter_server.extensions and or setuptools. I guess you need to pip install them. Worth checking also whether you have more than one versions of python installed as this may cause issues some times.

I'm getting ModuleNotFoundError: No module named _socket on ubuntu 18.04

I installed Anaconda3 on ubuntu and changed the path to ~/anaconda/bin in .bashrc file then I'm trying to install keras It's throwing this error.
hemanth#specter:~$ python3 -m pip install keras
Traceback (most recent call last):
File "/home/hemanth/anaconda3/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/home/hemanth/anaconda3/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/hemanth/anaconda3/lib/python3.7/site-packages/pip/__main__.py", line 16, in <module>
from pip._internal import main as _main # isort:skip # noqa
File "/home/hemanth/anaconda3/lib/python3.7/site-packages/pip/_internal/__init__.py", line 19, in <module>
from pip._vendor.urllib3.exceptions import DependencyWarning
File "/home/hemanth/anaconda3/lib/python3.7/site-packages/pip/_vendor/urllib3/__init__.py", line 8, in <module>
from .connectionpool import (
File "/home/hemanth/anaconda3/lib/python3.7/site-packages/pip/_vendor/urllib3/connectionpool.py", line 7, in <module>
from socket import error as SocketError, timeout as SocketTimeout
File "/home/hemanth/anaconda3/lib/python3.7/socket.py", line 49, in <module>
import _socket
ModuleNotFoundError: No module named '_socket'
I tried this command and it is working fine.
however, try to install socket using pip install sockets and then again try installing keras.

rpy2 doesn't work - requires libiconv.so.2

I have a relatively fresh installation of anaconda, in which I installed rpy2 using "conda install rpy2". However, when I try running it, I get this error, e.g.:
> /[dir]/anaconda/bin/python -m 'rpy2.tests'
Traceback (most recent call last):
File "/[dir]/anaconda/lib/python2.7/runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/[dir]/anaconda/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "[dir]/anaconda/lib/python2.7/site-packages/rpy2/tests.py", line 23, in <module>
import rpy2.tests_rpy_classic
File "/[dir]/anaconda/lib/python2.7/site-packages/rpy2/tests_rpy_classic.py", line 3, in <module>
import rpy2.rpy_classic as rpy
File "/[dir]/anaconda/lib/python2.7/site-packages/rpy2/rpy_classic.py", line 5, in <module>
import rpy2.rinterface as ri
File "/[dir]/anaconda/lib/python2.7/site-packages/rpy2/rinterface/__init__.py", line 92, in <module>
from rpy2.rinterface._rinterface import (baseenv,
ImportError: libiconv.so.2: cannot open shared object file: No such file or directory
What is this libiconv.so.2, and why doesn't it work straight from the box?
I think you need to conda install -c r libiconv or perhaps install r-essentials, which contains libiconv.

Sudden error in python 2.7

I had installed python 2.7 which was working fine till today. Suddenly it closed with an application error which it failed to capture and now everytime while running it its throwing the below mentioned error.
To give you a brief background the RAM memmory reahed to 95% which might have led to initial python crashing
Traceback (most recent call last):
File "C:\Python27\lib\runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "C:\Python27\lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "C:\Python27\lib\site-packages\scrapy-0.16.4-py2.7.egg\scrapy\cmdline.py"
, line 7, in <module>
from scrapy.crawler import CrawlerProcess
File "C:\Python27\lib\site-packages\scrapy-0.16.4-py2.7.egg\scrapy\crawler.py"
, line 3, in <module>
from twisted.internet import reactor, defer
File "C:\Python27\lib\site-packages\twisted\internet\reactor.py", line 38, in
<module>
from twisted.internet import default
File "C:\Python27\lib\site-packages\twisted\internet\default.py", line 56, in
<module>
install = _getInstallFunction(platform)
File "C:\Python27\lib\site-packages\twisted\internet\default.py", line 52, in
_getInstallFunction
from twisted.internet.selectreactor import install
File "C:\Python27\lib\site-packages\twisted\internet\selectreactor.py", line 1
8, in <module>
from twisted.internet import posixbase
File "C:\Python27\lib\site-packages\twisted\internet\posixbase.py", line 24, i
n <module>
from twisted.internet import error, udp, tcp
File "C:\Python27\lib\site-packages\twisted\internet\tcp.py", line 73, in <mod
ule>
from twisted.python.win32 import formatError as strerror
ImportError: cannot import name formatError
twisted module got corrupted due to the crash. Reinstalled the module and its working again.
It seems that some third-party packages are the ones at fault here. Try re-installing them or uninstalling them completely. If you are working with twisted try going up to python3, it has great support and hopefully the latest install fixed corruption issues.

Categories