By default, after python is installed in windows, the system does not automatically add corresponding environment variables. In this case, you cannot directly use Python commands in the command line.
1. first, you must register the python environment variable in the system. Assume that the python installation path is c: \ python2.6, modify the path in my computer> Properties> advanced> environment variables> system variables:
(To run the pythoncommand in the command line, add the directory of python.exe to the path environment variable .)
Path = path; C: \ python26
After the preceding environment variables are successfully set, you can directly use the python command on the command line. Or run "Python *. py" to run the Python script.
2. At this time, you can only run the Python script through "Python *. py". If you want to directly run *. py, you only need to modify another environment variable pathext:
Pathext = pathext;. py;. Pym
3. In addition, you may need to check the help document of a command frequently when using python, such as using help ('print ') to view the instructions for using the print command. Python installed by default cannot view the help documentation, and simple configuration is required:
In the python installation directory, find python25.chm and useHh-decompile. python26.chmDecompile it and add the directory to the PATH environment variable mentioned above.
4.How can I enable the python interpreter to directly import third-party modules other than the default installation path?
To import third-party modules (such as self-written modules) outside the default installation path, you need to create a new pythonpath environment variable with the value of the directory where the module is located.
When running The py file, I encountered a lot of problems. I went online to find others' experiences and found that it was basically none. I had to try it one by one. I come to the following conclusion, but I am not sure that I am absolutely right. I will only make corrections later.
If Python + filename is used, it must be ensured
(1) In command mode, it is not >>>.
(2) the file must be in the current directory or followed by a correct directory
(3) If environment variables are set, you can run them directly without adding the python command, but you can only run them in the directory where the file is located. But if you put the file under c: \ python26, you can run it in any directory ..