Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Collections (Retired) Lists Redux Shopping List Take Three

Dennis Le
Dennis Le
12,872 Points

Switching python2 to python3

Is there a way to use different versions of python? Have different python version ready to use...For example, if i need python 2.7 for one project and the next day I need python 3.5 for another project. Can I switch the version using just using the terminal...not sure on really how to ask this question...basically, I want to switch back and forth

2 Answers

Jorge Gimeno
Jorge Gimeno
5,956 Points

Look at a package called virtualenv. It allows you to set up separate "virtual enviroments" with their own Python interpreter and downloaded packages. Really handy when working on projects that use different versions of Python.

"python2 my_version2_program.py" to run python version 2. "python3 my_version3_program.py" to run python version 3.