Out of the blue, my python installation seems to have broken. When trying to run a python script, I get the following…
JavaScript
x
14
14
1
[michael@arch ~/Code/CTF/aero/house]$ ./solve.py
2
Traceback (most recent call last):
3
File "/home/michael/Code/CTF/aero/house/./solve.py", line 5, in <module>
4
from pwn import *
5
File "/home/michael/.local/lib/python3.9/site-packages/pwn/__init__.py", line 20, in <module>
6
pwnlib.update.check_automatically()
7
File "/home/michael/.local/lib/python3.9/site-packages/pwnlib/update.py", line 199, in check_automatically
8
log.info("n".join(message))
9
File "/home/michael/.local/lib/python3.9/site-packages/pwnlib/log.py", line 395, in info
10
self._log(logging.INFO, message, args, kwargs, 'info')
11
File "/home/michael/.local/lib/python3.9/site-packages/pwnlib/log.py", line 292, in _log
12
msg = six.ensure_text(msg)
13
AttributeError: module 'six' has no attribute 'ensure_text'
14
Trying to reinstall the module using pip also breaks…
JavaScript
1
28
28
1
[michael@arch ~/Code/CTF/aero/house]$ python3 -m pip install pwntools
2
Traceback (most recent call last):
3
File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
4
return _run_code(code, main_globals, None,
5
File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
6
exec(code, run_globals)
7
File "/usr/lib/python3.9/site-packages/pip/__main__.py", line 26, in <module>
8
sys.exit(_main())
9
File "/usr/lib/python3.9/site-packages/pip/_internal/cli/main.py", line 73, in main
10
command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
11
File "/usr/lib/python3.9/site-packages/pip/_internal/commands/__init__.py", line 105, in create_command
12
module = importlib.import_module(module_path)
13
File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
14
return _bootstrap._gcd_import(name[level:], package, level)
15
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
16
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
17
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
18
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
19
File "<frozen importlib._bootstrap_external>", line 790, in exec_module
20
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
21
File "/usr/lib/python3.9/site-packages/pip/_internal/commands/install.py", line 14, in <module>
22
from pip._internal.cache import WheelCache
23
File "/usr/lib/python3.9/site-packages/pip/_internal/cache.py", line 15, in <module>
24
from pip._internal.utils.temp_dir import TempDirectory, tempdir_kinds
25
File "/usr/lib/python3.9/site-packages/pip/_internal/utils/temp_dir.py", line 11, in <module>
26
from pip._vendor.six import ensure_text
27
ImportError: cannot import name 'ensure_text' from 'six' (/home/michael/.local/lib/python3.9/site-packages/six.py)
28
I have read that this is caused by running pip as root, but I have not done this. I also haven’t made any recent upgrades or installed any new packages. So far I have tried setting PYTHONPATH
, reinstalling python, and reinstalling pip, and none of these options have worked. Does anyone have any ideas? Thanks in advance!
EDIT: I also tried updating python and pip, which didn’t work.
Requested Information:
JavaScript
1
5
1
>>> import six; print(six.__file__)
2
/home/michael/.local/lib/python3.9/site-packages/six.py
3
>>> print(six.__version__)
4
1.10.0
5
Advertisement
Answer
I was able to update six by doing a wget https://raw.githubusercontent.com/benjaminp/six/master/six.py
in ~/.local/lib/python3.9/site-packages
. This solved the problem.