numpy 的安装路径和 pip show numpy 中的路径是一致的
时间: 2024-02-17 20:00:13 浏览: 26
如果 numpy 的安装路径和 `pip show numpy` 中的路径是一致的,那么可能是因为你在 Python 中使用了虚拟环境(virtualenv)或者 conda 环境,并且在这个环境中安装了 numpy 1.18.5。
你可以尝试激活这个虚拟环境或者 conda 环境,然后在 Python 中运行以下代码,查看 numpy 的版本:
```python
import numpy
print(numpy.__version__)
```
如果输出的版本是 1.18.5,那么说明你在这个环境中安装了这个版本的 numpy。你可以尝试在这个环境中升级 numpy 到 1.21.5:
```
pip install --upgrade numpy==1.21.5
```
或者如果你想完全移除 numpy 1.18.5,可以在这个环境中运行以下命令:
```
pip uninstall numpy
```
然后再重新安装 numpy:
```
pip install numpy==1.21.5
```
这样应该可以解决你的问题。
相关问题
pip show numpy显示的也是1.21.5
如果 `pip list` 和 `pip show numpy` 都显示 numpy 版本为 1.21.5,但是在 Python 中引用时却变成了 1.18.5,那么可能是因为你在 Python 的环境变量中添加了其他路径,导致 Python 找到了另一个版本的 numpy。
你可以在 Python 中运行以下代码,查看 numpy 的安装路径:
```python
import numpy
print(numpy.__file__)
```
这个路径应该和 `pip show numpy` 中的路径是一致的。如果不一致,那么说明你的 Python 环境中有多个 numpy,Python 找到了另一个版本的 numpy。你可以尝试在命令行中运行以下命令,查看 Python 的环境变量:
```
echo %PATH%
```
确保你的 Python 安装路径在环境变量中的优先级最高,这样才能保证 Python 找到正确的 numpy 版本。如果你发现其他路径在 Python 安装路径之前,你可以尝试将 Python 安装路径添加到环境变量的开头,或者将其他路径移除。
终端中怎么更改numpy的安装路径
1. 首先,使用命令 `pip show numpy` 查看当前 numpy 的安装路径。
2. 然后,使用命令 `pip uninstall numpy` 卸载当前的 numpy。
3. 接着,使用命令 `pip install --target=/your/new/path numpy` 安装 numpy 到新的路径。
4. 最后,使用命令 `pip show numpy` 验证 numpy 是否已经安装到新的路径。