如何在 PyCharm 中为所有项目安装包? [英] How do I install packages in PyCharm for all projects?

查看:129
本文介绍了如何在 PyCharm 中为所有项目安装包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 PyCharm 并且所有初始设置都没有问题.简单的包安装正在运行.那为什么我需要为每个项目重新安装一个包?从现在开始,有没有办法为所有项目安装包?

I use PyCharm and all the initial settings are okay.Simple package installation is working. Then why do I need to reinstall a package for each project? Is there any way to install the packages for all projects from now on?

推荐答案

这要看你的项目设置,具体的项目解释器.

This is depending on your project settings, the project interpreter to be specific.

项目解释器可以设置为以下之一:

The project interpreter can be set to one of the following:

  • 在您的系统上全局安装的解释器
  • 共享虚拟环境
  • 中的解释器
  • 与项目相关联的虚拟环境中的解释器

现在我推荐的方法是创建一个共享的虚拟环境,您可以在其中安装软件包,并将此环境用于您的所有项目.

Now the approach I'd recommend would be to create a shared virtual environment where you install your packages to, and use this environment for all your project.

这样,您就可以得到所需的结果,即只需要安装一次软件包,但仍然有一个与系统环境隔离的环境.

That way, you have the desired result of needing to install your packages only once, but still have an environment isolated from your system environment.

要创建这样的环境,请执行以下步骤:

To create such an environment, follow these steps:

  1. 设置 -> 项目 -> 项目解释器
  2. 点击解释器下拉菜单右侧的齿轮/齿轮图标
  3. 选择添加本地..."-> Virtualenv 环境
  4. 选择一个路径作为新环境的根目录
  5. 选择要使用的基本解释器
  6. 勾选复选框提供给所有项目"
  7. 点击确定"按钮保存新环境

这篇关于如何在 PyCharm 中为所有项目安装包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆