Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

How to create python 2.7 virtual environment using python 3.7

I have Python 3.7 && I would like to create a python 2.7 virtual environment to run some code that only works on python 2.7

How do I create this python 2.7 virtual environment?

python3 -m venv ?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

venv doesn’t allow creating virtual environments with other versions of Python than the one currently installed. You would have to use the traditional virtualenv package which allows creating virtual environments for different versions of python by providing the path to the binary like this:

virtualenv --python=/usr/bin/python2.7 /path/to/virtualenv/

where the path /usr/bin/python2.7 refers to the path of the binary for Python 2.7 on your system.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...