Using R and Python
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
- Data Services has additional instructions and screenshots for downloading Anaconda and using Jupyter Notebooks on GitHub. See our Python Installation Instructions and Jupyter Notebooks Tutorial to get started.
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
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.
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.
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.
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
- Python Documentation: Separated into beginner, moderate and advanced levels
- Python.org Help page: Links to FAQs and other places to get help with Python code
- 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:
- Biostatistics Center at School of Public Health: Provide statistics support to JHU faculty, staff and SPH graduate students. They have walk-in biostatistics consultations available online for several popular statistical software, such as R, SAS and STATA.
- Biostatistics, Epidemiology And Data management (BEAD) core: Provides statistics and data management support for JHU faculty. Sign up with their online intake form to start the process.
- Statistics support for Social Sciences and Behavioral Data by Bryce Corrigan, SNF Agora Institute at JHU. You can schedule an appointment with him using this form.