Setting environment variables mac

/ Etc / profile; / etc / bashrc is for all users of the system global variables, only the root user can modify these two files is that they are read-only for general users.

General users want to modify them, you can add sudo before the command is as Root mean execution, such as: sudo vi / etc / profile, and then follow the prompts to enter your password.

So, for the average user, we usually recommend to modify ~ / .bash_profile to set environment variables, which are user-level settings, only to the current user.

Steps:

1, open Terminal (Terminal)

2, input: vi ~ / .bash_profile

3, is provided PATH: exportPATH = "$ PATH: / usr / local / bin / python"

4. Enter :: wq // save and exit vi (note that in vi :)

5, modified with immediate effect: source ~ / .bash_profile

6, see the value of environment variable: echo $ PATH

Note: 1, ~ / .bash_profile There is a point

 

2, if the value of the new environment variable or modify environment variables, you need to source it to take effect immediately.

If you delete an environment variable, you must enter exit to logout the current shell, and then re-open a new shell and login to take effect

 

Python script execution carried out under Mac 
Mac into the terminal: Launch Pad - Other - Terminal
Python3.7 installation path is as follows:
cd /usr/local/bin/
 
Check the port number corresponding process 
lsof -i tcp: port port is the port number, such as 5037
If not occupied, no results are returned, otherwise there will be occupying the port number of processes and process id
Kill the corresponding id
kill port port is the port number 
 
See all python path. echo $ PATH 
View the current python version. python -version
View python3.7. Which python3.7 
 



Guess you like

Origin www.cnblogs.com/hc1hr2/p/10284755.html