pip报TypeError: ‘type‘ object is not subscriptable错误

这篇具有很好参考价值的文章主要介绍了pip报TypeError: ‘type‘ object is not subscriptable错误。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

因为安装 Manim库,中间下载 colour 组件时因为更新pip版本到 23.1.2 ,与python3.9.0 适配的 pip version 19.2.3 版本矛盾,导致后续无法正常使用python,出现如下报错:

C:\Users\Lenovo>pip list
Traceback (most recent call last):
  File "e:\etools\python 3.9.0\lib\runpy.py", line 193, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "e:\etools\python 3.9.0\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "E:\ETools\python 3.9.0\Scripts\pip.exe\__main__.py", line 5, in <module>
  File "e:\etools\python 3.9.0\lib\site-packages\pip\_internal\cli\main.py", line 10, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "e:\etools\python 3.9.0\lib\site-packages\pip\_internal\cli\autocompletion.py", line 10, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "e:\etools\python 3.9.0\lib\site-packages\pip\_internal\cli\main_parser.py", line 9, in <module>
    from pip._internal.build_env import get_runnable_pip
  File "e:\etools\python 3.9.0\lib\site-packages\pip\_internal\build_env.py", line 19, in <module>
    from pip._internal.cli.spinners import open_spinner
  File "e:\etools\python 3.9.0\lib\site-packages\pip\_internal\cli\spinners.py", line 9, in <module>
    from pip._internal.utils.logging import get_indentation
  File "e:\etools\python 3.9.0\lib\site-packages\pip\_internal\utils\logging.py", line 29, in <module>
    from pip._internal.utils.misc import ensure_dir
  File "e:\etools\python 3.9.0\lib\site-packages\pip\_internal\utils\misc.py", line 40, in <module>
    from pip._vendor.tenacity import retry, stop_after_delay, wait_fixed
  File "e:\etools\python 3.9.0\lib\site-packages\pip\_vendor\tenacity\__init__.py", line 397, in <module>
    FutureGenericT = futures.Future[t.Any]
TypeError: 'type' object is not subscriptable

修复 pip 的思路很简单,出问题的并不是 python ,而是因为 pip 的版本等级太高,因此想办法能够把 pip 的版本降低就可以了。
此时使用 pip --upgrade +指定版本号 的方法完全不能用,因为是 pip 整个无法使用,同样会出现上述的报错。

之后查看了一下文件的修改时间,找到可能是 pip 升级后改动的地方↓
pip报TypeError: ‘type‘ object is not subscriptable错误,pip,python,数学建模
于是找了台没安装过python 3.9 的电脑,安装了一次,然后继续报错:

C:\Users\Lenovo>pip
Traceback (most recent call last):
  File "E:\ETools\python 3.9.0\lib\runpy.py", line 193, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "E:\ETools\python 3.9.0\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "E:\ETools\python 3.9.0\Scripts\pip.exe\__main__.py", line 4, in <module>
ModuleNotFoundError: No module named 'pip._internal.cli.main'

解决这个ModuleNotFoundError: No module named 'pip._internal.cli.main'的问题,使用了这位大佬的方法:

文章《Python使用pip安装报错ModuleNotFoundError: No module named
‘pip._internal.cli.main‘的解决方法》:https://blog.csdn.net/qiguanjiezl/article/details/105762365

按照方法输入代码:

python -m ensurepip
python -m pip install --upgrade pip setuptools wheel

pip报TypeError: ‘type‘ object is not subscriptable错误,pip,python,数学建模
这个报错解决,输入 pip list 检查,发现又弹出之前的问题了,还是老问题TypeError: 'type' object is not subscriptable
pip报TypeError: ‘type‘ object is not subscriptable错误,pip,python,数学建模
没办法,继续找思路,然后在其他人询问的类似帖子里有人提到直接卸载旧python再安装。
pip报TypeError: ‘type‘ object is not subscriptable错误,pip,python,数学建模
因为是 pip 本身报错,所以甚至不能使用 pip 来卸载python,于是直接上程序面板大法:
pip报TypeError: ‘type‘ object is not subscriptable错误,pip,python,数学建模

其中,经过实际测试,必须要这两个都卸载才行,如果只卸载本体 python 3.9,而不卸载 python launcher 一样会重复上面的报错,问题没有得到改善

pip报TypeError: ‘type‘ object is not subscriptable错误,pip,python,数学建模
p.s. 在这一步时,也尝试过直接对这两个进行修复,答案是一样没有解决问题,所以最后还是选择了卸载
博主电脑里还有其他自带的python,比如Anaconda里自带的,但是最后实际结果证明,不用担心要不要把如Anaconda等一样自带python的都重新安装,不需要卸载他们就能解决

卸载后结果如下:
pip报TypeError: ‘type‘ object is not subscriptable错误,pip,python,数学建模
卸载之后重新安装 python 3.9 。

顺便一提,需要把原本安装 python 的目录下的所有文件全部删除,不然还是一样会报错。
如果不想把之前 pip 安装过的各种小插件之类的重新一个一个下载,可以在删除前把 Lib 文件夹整个复制到别的地方。
pip报TypeError: ‘type‘ object is not subscriptable错误,pip,python,数学建模
pip报TypeError: ‘type‘ object is not subscriptable错误,pip,python,数学建模
pip报TypeError: ‘type‘ object is not subscriptable错误,pip,python,数学建模

pip报TypeError: ‘type‘ object is not subscriptable错误,pip,python,数学建模
然后安装后,注意把这四个文件不要拷贝过去,会报错
pip报TypeError: ‘type‘ object is not subscriptable错误,pip,python,数学建模
python 3.9里正常的是这个:
pip报TypeError: ‘type‘ object is not subscriptable错误,pip,python,数学建模
安装完成后继续用 pip list 检测情况,
没有将之前的Lib复制过去时:
pip报TypeError: ‘type‘ object is not subscriptable错误,pip,python,数学建模
复制过去后:
pip报TypeError: ‘type‘ object is not subscriptable错误,pip,python,数学建模
至此,解决 pip报TypeError: 'type' object is not subscriptable错误 的问题。文章来源地址https://www.toymoban.com/news/detail-611809.html

到了这里,关于pip报TypeError: ‘type‘ object is not subscriptable错误的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • Stable Diffusion使用“面部修复”时报TypeError: ‘NoneType‘ object is not subscriptable错

    Stable Diffusion使用“面部修复”时报TypeError: ‘NoneType’ object is not subscriptable错 下载【detection_Resnet50_Final.pth】和【parsing_parsenet.pth】到【repositoriesCodeFormerweightsfacelib】目录下,并重新运行项目即可。 https://github.com/xinntao/facexlib/releases/download/v0.1.0/detection_Resnet50_Final.pth https:/

    2024年02月12日
    浏览(43)
  • python常见错误-TypeError: ‘int‘ object is not iterable

    可能大家在Python编程过程中经常会遇到​ ​TypeError: \\\'int\\\' object is not iterable​ ​的错误。这是因为我们尝试迭代一个整数对象,但Python无法迭代整数。 这个错误经常是用for循环迭代整数。例如以下代码: 运行以上代码会得到以下错误信息:TypeError: \\\'int\\\' object is not iterable 要解

    2024年04月14日
    浏览(29)
  • Python selenium中出现错误:driver = webdriver.chrome() TypeError: ‘module‘ object is not callable

    chrome的首字母应该为大写,如下: driver=webdriver.Chrome() 修改代码后程序即可正常运行 你也可以将路径传递给你的Chromedriver,将executable_path设置为你的chromedriver所在的位置(指向chromedriver.exe的路径,或者,对于非Windows用户,它被称为chromedriver): driver = webdriver.Chrome()是因为没有

    2024年02月12日
    浏览(38)
  • 解决报错TypeError: Object of type int32 is not JSON serializable

    当我们尝试将 numpy int32 对象转换为 JSON 字符串时,会出现 Python“TypeError: Object of type int32 is not JSON serializable”。 要解决该错误,请先将 numpy int 转换为 Python 整数,然后再将其转换为 JSON,例如 下面是错误如何发生的示例。 我们尝试将 numpy int32 对象传递给 json.dumps() 方法,但

    2024年02月06日
    浏览(45)
  • python 报错TypeError: ‘float‘ object is not callable

    python公式中少打了乘号“*”,如下图所示 一般是变量名与函数冲突,如本文中前面代码用到sum,后面直接用sum()函数同样报错,下图: 检查公式是否少打“*”号,python中对格式要求比较严格,不能直接用数学中省略符号的算式 调用函数,sum()函数用np.sum()函数 python报

    2024年02月10日
    浏览(32)
  • 【Python】成功解决TypeError: ‘float‘ object is not iterable

    【Python】成功解决TypeError: ‘float’ object is not iterable 🌈 个人主页:高斯小哥 🔥 高质量专栏:Matplotlib之旅:零基础精通数据可视化、Python基础【高质量合集】、PyTorch零基础入门教程👈 希望得到您的订阅和支持~ 💡 创作高质量博文(平均质量分92+),分享更多关于深度学习、

    2024年03月09日
    浏览(94)
  • 【python报错】TypeError: ‘int‘ object is not callable问题原因以及解决办法

    1.TypeError: ‘int’ object is not callable 报错原因 刚开始学python,在写一段代码的时候python报错:TypeError: ‘int’ object is not callable(int数据类型不能被调用) 出现这个问题的原因是:自己编写的代码中函数变量以及函数名称重复 2.解决办法:修改函数名称或者函数的变量名称,在

    2024年02月13日
    浏览(33)
  • Python-Json异常:Object of type Decimal is not JSON serializable

    使用python分离出一串文本,因为是看起来像整数,结果json转换时发生异常:TypeError: Object of type Decimal is not JSON serializable decimal格式不能被json.dumps正确处理。json.dumps函数发现字典里面有 Decimal类型的数据,无法JSON serializable 同样的问题也会出现在转换bytes数据时。 解决方法:

    2024年02月08日
    浏览(29)
  • 【已解决TypeError: ‘dict‘ object is not callable】

    情况1: 取字典内容的时候使用的是() 解决: 将()改为[ ] 情况2: 原来已经定义过dict函数,此时想使用python内置函数就会报错 可以看到如果我们先定义一个dict,那内置函数就会报错。 解决: 将之前定义的dict函数删掉 删除方法:你可以直接删掉函数重新运行,也可以

    2024年02月15日
    浏览(36)
  • Django代码中的TypeError ‘float‘ object is not callable

    学习使用Django进行网页爬取取决于你对Python、Django框架和网络爬虫的熟悉程度。以下是一些关键点,总的来说,如果你已经具备Python和Django的基础知识,并对网页爬虫有一定了解,那么学习使用Django进行网页爬取将会比较容易。如果你是一个完全的初学者,那么可能需要更多

    2024年01月24日
    浏览(33)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包