你可以更改 pip 安装软件包的目录如下:

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

How do I change the directory where pip installs packages?

问题

I have a problem where pip installs packages in the wrong directory: C:\Users\mikke\AppData\Roaming\python\python311\sitepackages, but my python is installed in C:\Program Files\Python311. I'm pretty new to python and use pycharm as my IDE, the problem I have is that pycharm doesn't recognize any of the packages I install, and I'm pretty sure it's because they are installed in the wrong directory.

First I tried to go on the internet to find answers on how to do this, but I couldn't find anything. Then I tried to go into my system variables and found out I had two different variables for python scripts, and one of the variables had the path: C:\Users\mikke\AppData\Roaming\python\python311\scripts, so I deleted the one with the path I didn't want my packages to go to, but it didn't work. Then I tried to uninstall pip, with the command: python -m pip uninstall pip, it deleted the pip exe's in the scripts folder, but when I tried to install the packages again it still installed in the wrong directory.

英文:

I have a ploblem where pip installs packages in the wrong directory: C:\Users\mikke\AppData\Roaming\python\python311\sitepackages, but my python is installed in C:\Program Files\Python311. I'm pretty new to python and use pycharm as my IDE, the problem i have is that pycharm doesn't recognize any of the packages I install and I'm pretty sure it's because they are installed in the wrong directory.

First I tried to go on the internet to find answers on how to do this, but I couldn't find anthing. Then I tried to go into my system variables and found out I had two different varibles to python script and one of the variables had the path: C:\Users\mikke\AppData\Roaming\python\python311\scripts, so i deleted the one with the path i didn't want my packages to go to, but it didn't work.
Then I tried to uninstall pip, with the command: python -m pip uninstall pip, it deleted the pip exe's in the scipts folder, but when i tried to install the packages again it still installed to the wrong directory.

答案1

得分: 1

PyCharm通常使用一种虚拟环境的选择,可以由项目进行选择。

有关如何查找给定项目的虚拟环境以及如何安装、卸载和升级包的更多信息,请参阅PyCharm文档此处

基本上,流程如下:

  1. 打开项目设置
  2. 选择Python解释器
  3. 单击+图标以添加新的Python包
英文:

PyCharm typically uses one of a selection of virtual environments, and this is selectable by project.

For more information on how to locate the virtual environment for a given project and how to Install, uninstall, and upgrade packages, see the PyCharm documentation here.

Essentially the process is:

  1. open project settings
  2. choose Python Interpreter
  3. click + icon to add a new Python package

huangapple
  • 本文由 发表于 2023年4月10日 21:45:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/75977668.html
匿名

发表评论

匿名网友

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

确定