centos 设置python环境变量
时间: 2023-03-19 07:24:04 浏览: 123
Python环境变量设置
To set the Python environment variable on CentOS, you can follow these steps:
1. Determine the path to your Python installation by running the following command:
```
which python
```
This will give you the path to the Python executable, which is usually `/usr/bin/python` for the system Python installation.
2. Set the `PATH` environment variable to include the path to your Python installation. You can do this by running the following command:
```
export PATH=/path/to/python/bin:$PATH
```
Replace `/path/to/python/bin` with the path to your Python installation. For example, if your Python executable is located at `/usr/bin/python3.6`, the command would be:
```
export PATH=/usr/bin/python3.6:$PATH
```
3. To make this change permanent, add the `export` command to your shell's configuration file (e.g. `~/.bashrc` for Bash). Open the file in a text editor and add the following line at the end:
```
export PATH=/path/to/python/bin:$PATH
```
Save the file and exit the editor.
4. Finally, reload your shell's configuration by running:
```
source ~/.bashrc
```
This will apply the changes to your current shell session. You can now verify that the Python environment variable is set correctly by running `python` or `python3` in the terminal.
阅读全文