我删除了一个包(pip),但它仍然有效。

huangapple go评论120阅读模式
英文:

i deleted a package(pip), but it still works

问题

因为torch(2.0.1)模块的问题,我想降级torch版本。
我删除了torch,安装了torch版本1.10.2,但仍然是python与torch 2.0.1一起工作。

所以我清理了pip缓存,删除了所有pip包(包括torch),卸载了python,并重新安装了python(3.9.7)。

现在在我的计算机上,模块'torch'没有安装,但下面的代码仍然可以工作。

import torch
print(f"Torch Version: {torch.__version__}")
# >>> Torch Version: 2.0.1+cpu

(在VS Code中)

C:\>pip uninstall torch
WARNING: Skipping torch as it is not installed.

我应该怎么办?

英文:

Because of the problem of torch(2.0.1) module, I want to downgrade torch version.
I deleted torch, install torch version 1.10.2, but still python was working with torch 2.0.1.

So I cleaned pip cache, delete all of pip package(including torch), uninstall python, and re-install python(3.9.7).

now in my computer, module 'torch' isn't installed, but below code is still working.

import torch
print(f"Torch Version: {torch.__version__}")
>>> Torch Version: 2.0.1+cpu

(vs code)

.
.

C:\>pip uninstall torch
WARNING: Skipping torch as it is not installed.

(cmd)

what would i do?

答案1

得分: 1

这看起来像是一个典型的错误使用了错误的Python版本的情况。

如果你使用python main.py来运行代码,例如,尝试使用python -m pip uninstall torch

这将强制使你的pip卸载命令使用与运行代码时相同的pip版本。

额外信息:python -m pip --version也会告诉你正在使用的Python版本以及其在文件系统中的位置。

英文:

This looks like a classic case of using the wrong Python.

If you run the code with python main.py, for example, try python -m pip uninstall torch.

This will force your pip uninstall command to use the same pip that you used when running your code.

Bonus: python -m pip --version will also tell you exactly which Python it is using and where it's located in your filesystem.

huangapple
  • 本文由 发表于 2023年8月5日 05:00:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/76839082.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定