使用命令行配置解释器
最后修改时间:2022 年 8 月 4 日从命令行启动 PyCharm 时,您可以指定用于新项目和现有项目的 Python 解释器。
使用预配置的 Python 解释器启动 PyCharm
您可以在安装目录的bin下找到用于运行 PyCharm 的可执行文件。要使用此可执行文件作为命令行启动程序,请PATH
按照命令行界面中所述将其添加到您的系统中。
在命令行中,执行以下命令来设置变量
PYCHARM_PYTHON_PATH
:>set PYCHARM_PYTHON_PATH=<PATH_TO_PYTHON>
替换
<PATH_TO_PYTHON>
为所需 Python SDK 可执行文件的路径。笔记
PYCHARM_PYTHON_PATH
此命令仅为当前 shell设置环境变量。从同一 shell 启动 PyCharm:
><PYCHARM_INSTALLATION_PATH>\bin\pycharm64.exe
<PYCHARM_INSTALLATION_PATH>
是 PyCharm 安装目录的路径。例如,C:\Program Files 。\JetBrains \PyCharm 如果您已将 PyCharm 可执行文件添加到
PATH
,只需键入pycharm
。
提示
您可以通过在启动 PyCharm 时提供项目文件夹的路径来打开现有项目。有关详细信息,请参阅从命令行打开文件。
默认情况下,PyCharm 不提供命令行启动器。有关为 PyCharm 创建启动器脚本的更多信息,请参阅命令行界面。
在命令行中,执行以下命令来设置变量
PYCHARM_PYTHON_PATH
:$PYCHARM_PYTHON_PATH=<PATH_TO_PYTHON>
替换
<PATH_TO_PYTHON>
为所需 Python SDK 可执行文件的路径。笔记
PYCHARM_PYTHON_PATH
此命令仅为当前 shell设置环境变量。从同一 shell 启动 PyCharm:
$open -na "PyCharm.app"
笔记
If PyCharm is not in the default /Applications directory, specify the full path to it.
If you have created a launcher script, just type
pycharm
.
tip
You can open an existing project by providing the path to the project folder when you launch PyCharm. For more information, refer to Open files from the command line.
You can find the script for running PyCharm in the installation directory under bin. To use this script as the command-line launcher, create a symbolic link in a directory from the PATH
environment variable as described in Command-line interface.
In the command line, execute the following command to set the
PYCHARM_PYTHON_PATH
variable:$export PYCHARM_PYTHON_PATH=<PATH_TO_PYTHON>
Replace
<PATH_TO_PYTHON>
with a path to the required Python SDK executable.note
This command sets the
PYCHARM_PYTHON_PATH
environment variable only for the current shell.Launch PyCharm from the same shell:
$sh <PYCHARM_INSTALLATION_PATH>/bin/pycharm.sh
<PYCHARM_INSTALLATION_PATH>
is the path to the PyCharm installation directory. For example,/opt ./pycharm/ If you have created a symbolic link to the launcher script, just type
pycharm
.
tip
You can open an existing project by providing the path to the project folder when you launch PyCharm. For more information, refer to Open files from the command line.
感谢您的反馈意见!