classification
Title: Error upon pip usage.
Type: crash Stage: resolved
Components: Library (Lib) Versions: Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: alki284, christian.heimes
Priority: normal Keywords:

Created on 2020-11-18 14:12 by alki284, last changed 2020-11-18 14:59 by alki284. This issue is now closed.

Messages (6)
msg381339 - (view) Author: Alex (alki284) Date: 2020-11-18 14:12
MacOS catalina 10.15.6
Python -version 3.9 although experienced on 3.8 too.
pip -version 20.2.4

Any time I send a command using pip including; pip install, pip freeze, pip list etc. I get this error.



Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.8/bin/pip", line 8, in <module>
    sys.exit(main())
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pip/_internal/cli/main.py", line 73, in main
    command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pip/_internal/commands/__init__.py", line 104, in create_command
    module = importlib.import_module(module_path)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pip/_internal/commands/list.py", line 9, in <module>
    from pip._internal.cli.req_command import IndexGroupCommand
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pip/_internal/cli/req_command.py", line 22, in <module>
    from pip._internal.req.constructors import (
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pip/_internal/req/__init__.py", line 10, in <module>
    from .req_install import InstallRequirement
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pip/_internal/req/req_install.py", line 10, in <module>
    import uuid
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/uuid.py", line 57, in <module>
    _AIX     = platform.system() == 'AIX'
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/platform.py", line 891, in system
    return uname().system
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/platform.py", line 857, in uname
    processor = _syscmd_uname('-p', '')
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/platform.py", line 613, in _syscmd_uname
    output = subprocess.check_output(('uname', option),
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py", line 411, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/run/__init__.py", line 145, in __new__
    process = cls.create_process(command, stdin, cwd=cwd, env=env, shell=shell)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/run/__init__.py", line 121, in create_process
    shlex.split(command),
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/shlex.py", line 311, in split
    return list(lex)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/shlex.py", line 300, in __next__
    token = self.get_token()
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/shlex.py", line 109, in get_token
    raw = self.read_token()
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/shlex.py", line 140, in read_token
    nextchar = self.instream.read(1)
AttributeError: 'tuple' object has no attribute 'read'
msg381341 - (view) Author: Alex (alki284) Date: 2020-11-18 14:15
I tried contacting the pip team and they said it is likely a python issue due to the stdlib stuff being opened.
msg381342 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2020-11-18 14:18
"/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/run/__init__.py" looks suspicious. It's a 3rd party package that is somehow injected into the code.
msg381343 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2020-11-18 14:21
Upon closer investigation something or someone has replaces and monkey patched the stdlib function subprocess.run() with code from the 3rd party library "run". The "run" package is not part of Python's stdlib.
msg381346 - (view) Author: Alex (alki284) Date: 2020-11-18 14:24
What would you recommend to fix this? removing the package? I have a suspicion on which package it is.
msg381350 - (view) Author: Alex (alki284) Date: 2020-11-18 14:59
Uninstalled 3.8 and installed straight to 3.9 using home brew, this fixed the issue.
History
Date User Action Args
2020-11-18 14:59:42alki284setstatus: open -> closed
resolution: fixed
stage: resolved
2020-11-18 14:59:24alki284setmessages: + msg381350
2020-11-18 14:24:56alki284setmessages: + msg381346
2020-11-18 14:21:30christian.heimessetmessages: + msg381343
2020-11-18 14:18:37christian.heimessetnosy: + christian.heimes
messages: + msg381342
2020-11-18 14:15:41alki284setmessages: + msg381341
2020-11-18 14:12:57alki284create