Using R and Python

This libguide covers resources for learning and using R and Python.

Data Services Profile

We are here to help you find, use, manage, visualize and share your data. Contact us to schedule a consultation. View and register for upcoming workshops. Visit our website to learn more about our services.

License

These materials are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License, attributable to Data Services, Johns Hopkins University.

Download and Install Python

There are several options for how to install and set up python on your computer; if you plan to use python for multiple projects, we strongly recommend using a virtual environment manager like Anacondas or minicondas, rather than installing python directly onto your computer. To learn more about virtual environments and why we recommend them for reproducible research, see the following resources:

Recommended Option: Install the Anaconda distribution (includes Python and a development environment)
  • You can also install Python and many common data science packages through the Anaconda distribution. Data Services frequently uses Jupyter Notebooks and other Anaconda distribution products in our workshops. You can download Anaconda here.
Data Services Tutorials
Alternate Option: Install Python and use your own development environment
  • Python can be downloaded and installed on Windows, Linux/Unix, Mac OS X, and other platforms. You can download the latest version of Python (version 3.X) from www.python.org/downloads/.

Choosing an IDE (Integrated Development Environment)

What is an IDE?

Integrated Development Environments, or IDEs, are desktop applications that are designed to make software development easier. In Python, you will use an IDE to write your code and run your programs. Choosing an IDE  is an essential part of programming in Python.

Some IDEs are general and allow users to write and run code in multiple languages. Other IDEs are made for a specific programming language, such as Python, or task, such as machine learning.

Common features of IDEs that can help you write code are code completion, syntax highlighting, debugging, environment managers, version control, and auto-refactoring. You can choose an IDE based on the features you want to use.

How to choose an IDE:

We recommend choosing an IDE based on your comfort level with Python, other programming languages you use, and the tasks you are trying to complete. A few questions that may guide you to the right IDE for your purposes are:

What is your level of programming knowledge?

Some IDEs will be better for beginners or have more advanced features

What other language(s) do you code in?

If you use multiple programming languages, you may want one IDE that can accommodate all of them

What tasks are you trying to accomplish?

IDEs will have features that are useful for different tasks, such as machine learning or visualizing data

How do you want to share your code?

Some IDEs may make it easier to share your code on GitHub or other cloud environments

Will you always be working from the same computer?

Some IDEs may make it easier to save your code in a cloud environment

What are your collaborators using?

Using the same IDE as your collaborators or colleagues can help you find a user community to help with troubleshooting and making the most of IDE features

Python IDEs

There are many IDEs that support Python code. Some of the common IDEs you may want to consider are:

  • Jupyter Notebooks and JupyterLab: Jupyter Notebooks are free, interactive notebooks for writing and running Python code. JupyterLab is a newer version of the traditional notebook. Both are great options for writing, running, and sharing reproducible Python code. You can install Jupyter Notebooks and JupyterLab directly from jupyter.org. Both IDEs are also included in the Anaconda distribution.

  • Visual Studio Code: A free source-code editor by Microsoft for Windows, Linux, and macOS. The Python extension can be downloaded through VS Code.

  • PyCharm: An IDE made for coding and software development in Python, developed by JetBrains. Has a full-feature paid version and a free, open source version. The full-feature, paid version is typically available for free to users at academic institutions.

  • Spyder: A free, open source IDE designed for scientific computing and visualization in Python. It comes with Anaconda for Python installation.

  • Thonny: a free IDE that is geared toward Python beginners. It may not have all the features developers want for software development and maintenance.

  • IDLE: IDLE is Python's own desktop IDE. It has basic features including syntax highlighting and code completion, a simple interface, and is good for Python beginners. IDLE is typically included when you download Python on your computer.

  • RStudio: Originally designed for R, RStudio is a free desktop IDE that fully supports Python code. It is a great option for users of both R and Python.

  • Eclipse: An IDE designed primarily for Java developers. Python users can install the PyDev plugin to use Python in the Eclipse IDE.

  • Replit.com: A free, browser-based IDE for Python and many other languages. Replit.com is great for beginners and allows users to access code from a cloud environment, with no download required.

  • Google Colab: An online, interactive notebook for Python code. Google Colab makes it easy for users to share and access code from any computer.

Get Help Using Python

Documentation:
Online forums:
  • Stack Overflow: A platform for people to ask technical questions and find answers to them. Questions on this forum are not limited to R.
  • Cross Validated: A Q&A forum for questions related to statistics, machine learning, data analysis, data visualization and data mining. Questions on this forum are not limited to Python.
  • Python discuss forum: Online Q&A forum for Python users
Statistical consulting services at JHU: