简体   繁体   English

PyCharm是否可以为同一项目提供多个conda环境变量

[英]Can PyCharm have multiple conda environment variables for the same project

There are many discussions on how to use conda environment variables in PyCharm projects. 关于如何在PyCharm项目中使用conda环境变量的讨论很多。 These discussions, however, often assume that for each PyCharm project only one conda environment variable is used. 但是,这些讨论通常假设每个PyCharm项目仅使用一个conda环境变量。 Then here is my question: is it possible to have multiple conda enviroment variables for the same project? 然后这是我的问题:同一项目是否可能有多个conda环境变量? I give the following example to make my point much clearer: 我给出以下示例以使我的观点更加清楚:

pycharm_project_name
      abc.py       (use conda environment variable: TensorFlow)
      def.py       (use conda environment variable: Caffe)

In this example, the PyCharm project has two python scripts with each depending on its own environment variable. 在此示例中,PyCharm项目具有两个python脚本,每个脚本均取决于其自身的环境变量。 In this case, how could I set the PyCharm project in a proper way? 在这种情况下,如何正确设置PyCharm项目?

If your goal is to run the scripts within a particular environment, this is easily acomplished using different run configurations for the different scripts. 如果您的目标是在特定环境中运行脚本,则可以通过对不同脚本使用不同的运行配置来轻松完成此任务。 This will allow you to select the configuration from the dropdown and click play to run it. 这将允许您从下拉列表中选择配置,然后单击播放以运行它。

运行配置菜单

The run configuration dialog has a "Python interpreter" option, where you can select the environment to run in. 运行配置对话框具有“ Python解释器”选项,您可以在其中选择要运行的环境。

Unfortunately, there is no simple way to configure different environments for the other popular way of running scripts, which is to right click on them and select the run option from there. 不幸的是,没有一种简单的方法可以为运行脚本的另一种流行方式配置不同的环境,即右键单击它们并从中选择运行选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM