PIP安装软件包 - 安装,但Python没有导入

发布于 2025-01-19 11:52:04 字数 603 浏览 0 评论 0原文

在 Windows 10 上运行,我已将 Python 3.7.3 安装到我的 c/users/myUser/appdata/local/programs 文件夹中。 当我使用 PIP 安装包时,它似乎运行良好,但是当我在 python 中使用“导入包”时,它无法识别该包。什么会导致这种情况呢?

运行“python --version”有效,运行“pip --version”也有效。

PIP 显示在我的 c/users/myUser/appdata/local/programs/python37-32/lib/site-packages/pip 文件夹中。

更新: 因此,我正在查看文件以确定与我的 python 兼容的库所在的位置。该文件夹位于Python/Python37-32/Lib。所有这些目前在导入时都有效。但是,当我使用 PIP 执行任何操作时,它不会向该文件夹添加任何内容。 我注意到 Python/Python37-32/Scripts 中有几个不同的 PIP 可执行文件,其中包括 pip.exe、pip3.exe 和 pip3.7.exe。我尝试使用“pip3.7 install numpy”,但这也不起作用。 我注意到,当尝试添加现有包时,它指向 Python37-32/lib/site-packages 文件夹。

Running on Windows 10, I have Python 3.7.3 installed to my c/users/myUser/appdata/local/programs folder.
When I use PIP to install a package, it seems to run fine, but when I use "import package" in python it doesn't recognize that package. What would cause this?

Running 'python --version' works and also running 'pip --version' works.

PIP shows up in my c/users/myUser/appdata/local/programs/python37-32/lib/site-packages/pip folder.

UPDATE:
So I was looking through files to determine where the libraries are located that do work with my python. The folder is located in Python/Python37-32/Lib. All of those currently work when importing. However when I do anything with PIP it does not add anything to that folder.
I noticed there are a couple different PIP executables within Python/Python37-32/Scripts which include pip.exe, pip3.exe, and pip3.7.exe. I tried using "pip3.7 install numpy" which also did not work.
I noticed when trying to add an existing package its pointing to the Python37-32/lib/site-packages folder.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我乃一代侩神 2025-01-26 11:52:04

解决方案:

我将Python从机器上取出,然后重新安装。我遇到了同样的问题。我为解决此问题所做的就是使用

PS
Python -M PIP安装 - 用户软件包

我也将路径环境变量附加

CMD
setx路径“%路径%; c:\ users \ myuser \ appdata \ roaming \ python \ python \ python38 \ scripts”

似乎已经解决了我的问题。现在,当我安装带有PIP的软件包时,我可以通过Python引用它。

SOLUTION:

I removed python from my machine, and reinstalled it. I had the same problem. What I done to fix this was to use

PS
python -m pip install --user package

Also I appended my PATH environment variable with

cmd
setx path "%path%;C:\Users\MyUser\AppData\Roaming\Python\Python38\Scripts"

That seemed to have taken care of my issue. Now when I install a package with PIP I can reference it through python.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文