gpt4 book ai didi

python - 模块六没有属性 ensure_text

转载 作者:行者123 更新时间:2023-12-05 03:42:57 25 4
gpt4 key购买 nike

出乎意料的是,我的 python 安装好像坏了。尝试运行 python 脚本时,我得到以下信息...

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

尝试使用 pip 重新安装模块也会中断...

[michael@arch ~/Code/CTF/aero/house]$ python3 -m pip install pwntools
Traceback (most recent call last):
File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/usr/lib/python3.9/site-packages/pip/__main__.py", line 26, in <module>
sys.exit(_main())
File "/usr/lib/python3.9/site-packages/pip/_internal/cli/main.py", line 73, in main
command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
File "/usr/lib/python3.9/site-packages/pip/_internal/commands/__init__.py", line 105, in create_command
module = importlib.import_module(module_path)
File "/usr/lib/python3.9/importlib/__init__.py", 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/install.py", line 14, in <module>
from pip._internal.cache import WheelCache
File "/usr/lib/python3.9/site-packages/pip/_internal/cache.py", line 15, in <module>
from pip._internal.utils.temp_dir import TempDirectory, tempdir_kinds
File "/usr/lib/python3.9/site-packages/pip/_internal/utils/temp_dir.py", 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/six.py)

我读到这是由以 root 身份运行 pip 引起的,但我没有这样做。我也没有进行任何最近的升级或安装任何新软件包。到目前为止,我已尝试设置 PYTHONPATH、重新安装 python 和重新安装 pip,但这些选项均无效。有人有什么想法吗?提前致谢!

编辑:我还尝试更新 python 和 pip,但没有用。

请求的信息:

>>> import six; print(six.__file__)
/home/michael/.local/lib/python3.9/site-packages/six.py
>>> print(six.__version__)
1.10.0

最佳答案

python3 -m pip install --upgrade six

您最好在虚拟环境中执行此操作。

关于python - 模块六没有属性 ensure_text,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67063538/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com