Python: Check the position of interpreter

Previously learn Python, and sometimes this happens: obviously remember scipy package installed, how to play import scipy error saying I did this package?

The problem is, more than a Python installed on your computer ...

And each installation of a package, just in the Python installation path in the Lib \ site-packages \, in the other there is not.

Here are a very lightweight software Everything, it's easy to quickly find your local computer in a file. We enter python.exe, actually found out a bunch of python ...:

If using regular expressions, also found more:

 

 

In fact, many software installation will automatically install the bundled Python, but we turn a blind eye. As shown, I've included ArcGIS, QGIS, PostgreSQL, SPSS, and even Pycharm virtual environment.

Computer when executing a Python program, will use the interpreter (python.exe) (pythonw.exe in fact is the same, but it is no GUI). In the command line input python out of the system environment variables in the first python.

In fact, enter cmd where python can also be found in default of a Python.

So how do we view the current use of a python which is inside of it? (Path location interpreter?)

Method One (indicate the location and name of interpreter):

In the shell command line, enter:

Import SYS
 Print (sys.executable) # interpreter

Method 2 (If you just want to view the path of words):

In the shell command line, enter:

Import SYS 
Import os
Print (os.path.dirname (sys.executable)) # file folder where the interpreter

Here the shell command line, refers to the python. After entering cmd python, python own shell, python console QGIS in, ArcGIS in python ... can row.

 

 

 

Guess you like

Origin www.cnblogs.com/maoerbao/p/11519013.html