Pietro Speroni
Pietro Speroni

Reputation: 3221

which python is running?

We have a python program that is running in a virtual env linux Debian. We want to install pypy, and it is working perfectly... except we are not sure it is actually using pypy.

So we started changing the name of the standard python, taking away pypy, taking away all the internal link, deleting all the .pyc files.

and the system does not just keep running, but it also runs again if I stop it, and run it again.

Is there a way to write a command in pything and find (1) what version of pythong is running; (2) where in the cd this version is,

Thanks

Upvotes: 0

Views: 210

Answers (1)

alvas
alvas

Reputation: 122052

Try:

>>> import sys
>>> sys.executable
'/usr/bin/python'
>>> sys.version
'2.7.11 (default, Dec 15 2015, 16:46:19) \n[GCC 4.8.4]'

Edited

From @zondo:

>>> import sys
>>> sys.version_info
sys.version_info(major=2, minor=7, micro=11, releaselevel='final', serial=0)
>>> sys.version_info.major
2

Upvotes: 3

Related Questions