Managing Python Virtual Environments on WRDS

Slide Note
Embed
Share

Understanding and creating virtual environments on WHARTON RESEARCH DATA SERVICES (WRDS) allows users to isolate Python packages for different projects, ensuring compatibility and preventing conflicts. This guide covers creating, activating, deactivating, and using pip to install Python packages within virtual environments on WRDS.


Uploaded on Jul 17, 2024 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. WHARTON RESEARCH DATA SERVICES Python Virtual Environments on WRDS Ted Donohue June, 2020

  2. 1 What is a virtual environment? 2 Creating a virtual environment on WRDS 3 Activating & deactivating your virtual environment 4 Using pip to install python packages 2 Wharton Research Data Services

  3. What is a Virtual Environment? An environment for your user account Install python packages without adversely affecting other users Use different sets of packages for different projects Project A requires Pandas 1.0 Project B requires Pandas 0.25 Solution ... create 2 separate virtual environments 3 Wharton Research Data Services

  4. 1 What is a virtual environment? 2 Creating a virtual environment on WRDS 3 Activating & deactivating your virtual environment 4 Using pip to install python packages 4 Wharton Research Data Services

  5. Creating a Virtual Environment The python m venv command tells python it is creating a virtual environment The --system-site-packages parameter indicates that the packages already installed in the server s main python instance should also be included in the virtual environment The ~/virtualenvs/environment01 directory path parameter indicates where the virtual environment should be created 5 Wharton Research Data Services

  6. Creating a Virtual Environment Leaving out the --system-site-packages parameter will create an empty virtual environment with only base python packages installed. Also note that the ~/virtualenvs/environment01 path with create the virtual environment directory environment01 as a subdirectory of virtualenvs . If you think you will need more than one virtual environment, this will keep them within a common location. 6 Wharton Research Data Services

  7. 1 What is a virtual environment? 2 Creating a virtual environment on WRDS 3 Activating & deactivating your virtual environment 4 Using pip to install python packages 7 Wharton Research Data Services

  8. Activate & Deactivate Virtual Environment The environment can be activated with the command source [virtual environment path]/bin/activate. The path will depend on the directory path you chose in the prior step. When the environment is successfully activated you will see its name at the command prompt, as seen above. To exit the virtual environment, simply enter the deactivate command. You should no longer see the environment name at the prompt. 8 Wharton Research Data Services

  9. 1 What is a virtual environment? 2 3 Creating a virtual environment on WRDS Activating & deactivating your virtual environment 4 Using pip to install python packages 9 Wharton Research Data Services

  10. 1 What is a virtual environment? 2 Creating a virtual environment on WRDS 3 Activating & deactivating your virtual environment 4 Using pip to install python packages 10 Wharton Research Data Services

  11. Using pip to Install Python Packages The pip command can be used within an activated virtual environment to install a packaged. For a searchable python package index, visit https://pypi.org/ 11 Wharton Research Data Services

  12. Using pip to Install Python Packages The command pip freeze will display a list of all the packages that are currently installed in the environment. 12 Wharton Research Data Services

  13. T h a n k Yo u !

Related


More Related Content