Module Six has no attribute ensure_text

  arch, pip, pwntools, python, python-3.x

Out of the blue, my python installation seems to have broken. When trying to run a python script, I get the following…

[[email protected] ~/Code/CTF/aero/house]$ ./ 
Traceback (most recent call last):
  File "/home/michael/Code/CTF/aero/house/./", line 5, in <module>
    from pwn import *
  File "/home/michael/.local/lib/python3.9/site-packages/pwn/", line 20, in <module>
  File "/home/michael/.local/lib/python3.9/site-packages/pwnlib/", line 199, in check_automatically"n".join(message))
  File "/home/michael/.local/lib/python3.9/site-packages/pwnlib/", line 395, in info
    self._log(logging.INFO, message, args, kwargs, 'info')
  File "/home/michael/.local/lib/python3.9/site-packages/pwnlib/", line 292, in _log
    msg = six.ensure_text(msg)
AttributeError: module 'six' has no attribute 'ensure_text'

Trying to reinstall the module using pip also breaks…

[[email protected] ~/Code/CTF/aero/house]$ python3 -m pip install pwntools
Traceback (most recent call last):
  File "/usr/lib/python3.9/", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.9/", line 87, in _run_code
    exec(code, run_globals)
  File "/usr/lib/python3.9/site-packages/pip/", line 26, in <module>
  File "/usr/lib/python3.9/site-packages/pip/_internal/cli/", line 73, in main
    command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
  File "/usr/lib/python3.9/site-packages/pip/_internal/commands/", line 105, in create_command
    module = importlib.import_module(module_path)
  File "/usr/lib/python3.9/importlib/", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 790, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/usr/lib/python3.9/site-packages/pip/_internal/commands/", line 14, in <module>
    from pip._internal.cache import WheelCache
  File "/usr/lib/python3.9/site-packages/pip/_internal/", line 15, in <module>
    from pip._internal.utils.temp_dir import TempDirectory, tempdir_kinds
  File "/usr/lib/python3.9/site-packages/pip/_internal/utils/", line 11, in <module>
    from pip._vendor.six import ensure_text
ImportError: cannot import name 'ensure_text' from 'six' (/home/michael/.local/lib/python3.9/site-packages/

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.

Source: Python-3x Questions