How to create your own Python environment


Financial Modelling Prep provides a free stock API, financial statement API, and lots more valuable financial data. Before you can start taking advantage of our service you must first set up the environment where you are going to write your code. In this guide, we will explain exactly how to do this:

  1. Download and Install Anaconda
  2. Launch Jupyter Lab and Create Your Folders
  3. Launch a Notebook and Start Coding!

Step 1: Download and install Anaconda

Anaconda is one of the leading python and data science platforms. It enables you to be able to have your own Jupyter Notebook style environment to write your code and run your analysis. The Jupyter Notebook environment is great for beginners to intermediate coders because it allows you to run individual blocks of code and get their specific outputs. Everything in one notebook will be connected so it makes it much easier to debug your code and figure out the exact location of any errors. Anaconda enables you to create your own Juptyer Notebook environment that will store your files locally on your PC or Mac. Here are the instructions from Anaconda on how to install it on your Mac or Windows PC:

Windows Install Guide:

  1. Download the Anaconda installer
  2. RECOMMENDED: Verify data integrity with SHA-256. For more information on hashes, see What about cryptographic hash verification?
  3. Double click the installer to launch.
  4. Click Next.
  5. Read the licensing terms and click “I Agree”.
  6. Select an install for “Just Me” unless you’re installing for all users (which requires Windows Administrator privileges) and click Next.
  7. Select a destination folder to install Anaconda and click the Next button. See FAQ
  8. install
  9. Choose whether to add Anaconda to your PATH environment variable. We recommend not adding Anaconda to the PATH environment variable, since this can interfere with other software. Instead, use Anaconda software by opening Anaconda Navigator or the Anaconda Prompt from the Start Menu.
  10. install

macOS Install Guide:

  1. Download the graphical macOS installer for your version of Python.
  2. RECOMMENDED: Verify data integrity with SHA-256. For more information on hashes, see What about cryptographic hash verification?
  3. Double-click the downloaded file and click continue to start the installation.
  4. Answer the prompts on the Introduction, Read Me, and License screens.
  5. Click the Install button to install Anaconda in your ~/opt directory (recommended):
  6. install
  7. OR, click the Change Install Location button to install in another location (not recommended). On the Destination Select screen, select Install for me only.
  8. Click the continue button
  9. A successful installation displays the following screen:
  10. install

Step 2: Launch Jupyter Lab and Create Your Folders

Now that you’ve installed Anaconda, it is time to launch JupyterLab and start making your environment your own. First you will need to open the Anaconda Navigator. Don’t be scared by the seemingly scary command centre code it runs when you open it - this is normal and won’t harm your computer. Once you’ve launched Anaconda Navigator you’ll be asked to make an account which is not necessary to get started so we recommend you ignore this. You should get to a screen like this:

install

Click the Launch Button underneath JupyterLab which is highlighted above. This will take you to a new tab on your preferred browser and will look something like this:

install

Once successfully launched, you’ll want to create a new folder and name whatever makes the most sense to you (We called ours FMP because we’re biased!). Below you’ll see that the new folder button is highlighted:

install

After you’ve created the main folder that you’ll store all your work, spend some time thinking about how to organize your subfolders. We recommend creating a new folder for each project you take on and putting all your work for that project in that folder. This will likely be multiple Jupyter notebooks and other files such as CSVs. Below is an example of the folder structure we have used:

install

Step 3: Launch a Notebook and Start Coding!

So now your environment is all set up, it is time to start writing some code and performing analysis using Python. To start, perhaps create a folder called “Learning” or something similar to store all of your notebooks used to get started and learn new skills. To open the folder, simply double click it. To navigate back press the name of the main folder. To open your first notebook click the tile beneath the Notebook header that says “Python 3” and a new notebook will open!

install

By default, this notebook will be untitled. To rename the notebook either right-click the file in the left-hand side or at the top of the tab and then select rename. These two are highlighted below:

install

To make sure Jupyter is working properly always run a simple test bit of code and make sure the output works well. For example, try typing the following into the first cell:

x = 7 * 5

x

Then hit enter.

You should of course get an output of 35

install

If you want to create a new notebook, click the + icon in the top left corner of Jupyter and it will bring up a new launcher where you can follow the steps above to begin a new notebook.

Rounding Up

So that’s how you can get your Python coding environment set up and start coding. First, download and install Anaconda. Then, launch JupyterLabs and create your folder structure. Finally, launch your first notebook and test it works before beginning your coding adventure!