Finding the directory that python is installed in.. (CENTOS) and using it for virutalenv’s path

assuming the following command returns a version of Python 3 you can find where it is installed using the sys object..

(see if python3 has been installed.)
python3 –version

In my case it returns

Python 3.5.0
If python 3.x has not been installed..

to find the location of the install for use with Virtualenv..

at the $ type python3 (this should launch python3)

import sys

The import line gives you sys lib functionality and sys.executable will tell you where it is.. now you can create a virtual environment that uses python3

e.g. $ virtualenv -p /usr/local/bin/python3 py3envtest

will generate a virutal env for python3 in the directory of py3envtest.
to activate the virutalenv you will need to change into the directory of py3envtest and execute the following command

. bin/activate

Done! not typing python should automatically run the version that virtualenv had specified.


Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>