Back to Community
Python 2 or 3

I am giong to teach myself Python. Should I learn Python 3 or 2 for Quantopian?

11 responses

Quatopian currently is on version 2.7. (see below for specifics))

What you really need to learn are all the methods provided by Pandas and Numpy. Most of the data structures you will be dealing with in Quantopian are either Pandas dataframe objects or Numpy array or series objects. These objects come with a lot of methods built in. You will probably be mostly using those methods once you get the hang of the basic Python syntax and conventions. See http://www.numpy.org/ and http://pandas.pydata.org/ and http://pandas.pydata.org/pandas-docs/stable/10min.html

You are using Jupyter notebook.

The version of the notebook server is 4.3.1 and is running on:  
Python 2.7.12 (default, Jul 18 2016, 15:02:52)  
[GCC 4.8.4]

Current Kernel Information:

Python 2.7.12 (default, Jul 18 2016, 15:02:52)  
Type "copyright", "credits" or "license" for more information.

IPython 5.3.0 -- An enhanced Interactive Python.  
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.  
object?   -> Details about 'object', use 'object??' for extra details.  

This is for the notebook environment

As someone who also just starts to learn python, I really don't appreciate having to spend time on a dying language

Hmm.. Python dying? A lot of banks and financial institutions (including quant funds) use Python or are moving in that direction. http://news.efinancialcareers.com/us-en/137065/the-six-hottest-programming-languages-to-know-in-banking-technology/

I mean Python 2, Dan

In my experience they aren't very different. I started learning python last year and went with 3. I figured it would be easier to begin with the future and then deal with any incompatibilities with python 2. I've yet to have a single issue on Quantopian where the version made a difference.

I used Python forever ago and recently just got back into things, mainly for Quantopian. I started writing some scripts in Python 3.7, just to get re-familiarized. Much to my surprise though, Quantopian Jupyter notebooks are still on Python 2.x? For example, I found that f-strings don't work, which is a > Python 3.6 feature:

date = '2018-12-18'  
f_date = f"The date is: {date}"  
print(f_date)  

Is there a setting or way somewhere to toggle the 3.x Python version of Jupyter notebooks in the Q Research environment? It'd be really nice to use Python 3.7.

I have the same concern, very annoying that I must toggle back to Python 2.7 and am not sure if I write a script with Quantopian in 3.7 whether it will always run. Are there any plans to update along with Python?

Hi @Chris,

We hear you (and others on this thread) and we're sorry that you have to go through the frustrating experience of switching back and forth between different versions. We recently started planning out how we are going to upgrade Quantopian from Python 2 to Python 3. We don't yet have any material to share, but our first step will be to announce our plan to the community once we have something more concrete.

Thanks for the feedback.

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

Thank you for the swift response, good to hear that plans are in motion. I'll stay tuned for the update, and appreciate the effort required on your side is also very high.

Python2 will be officially discontinued (i.e no updates/fixes will be made) from Dec 1st, 2020. Is there a plan to switch to python 3 before that ?

Good timing! We just posted an update on our plans to upgrade to Python 3 here.