Skill - Install and manage python packages
Skills Required
Please make sure to have all the skills mentioned above to understand and execute the code mentioned below. Go through the above skills if necessary for reference or revision
In this post we will learn how to use the pip
command to manage python packages
Install a python package
- Open command prompt
- Use command
pip install <package_name>
- For example, to install a package named pandas, you need to run
pip install pandas
Install specific version of a python package
- Open command prompt
- Use command
pip install <package_name>==<version_number>
- For example, to install a package named numpy with version 1.11.1, you need to run
pip install numpy==1.11.1
list all the packages in a python environment
- Open command prompt
- Use command
pip list
- All the installed python packages along with their version numbers will be displayed
install packages from a file using ‘-r’ flag
- If we have a text file named
requirements.txt
with packages information as shown below
MySQL-python==1.2.3
WebOb==1.2.3
numpy==1.11.1
- We can install all the packages from the file like the one file shown above using the following command
pip install -r requirements.txt
- To install packages from a file located at a specific path, use a command something like the one below
pip install -r C:\Users\Nagasudhir\Documents\requirements.txt
dump all the packages information into a text file
- In order to dump the installed packages information of the current python environment use the following command
pip freeze > requirements.txt
Further Reading
Video
The video for this post can be seen here
Comments
Post a Comment