204 lines
2.9 KiB
Markdown
204 lines
2.9 KiB
Markdown
***
|
||
|
||
## Shrocuts
|
||
***
|
||
* `Ctrl+K Ctrl + 0` : para minimizar o colapsar todas las funciones de una sola vez
|
||
* `Shift + Ctrp + P` : Add ignore -> Python : antes de crear el repositorio
|
||
|
||
|
||
|
||
# Python Package Management: pip and pipreqs Commands Reference
|
||
|
||
## pip - Python Package Installer
|
||
|
||
### Basic Commands
|
||
|
||
- **Install a package**:
|
||
|
||
```
|
||
pip install package_name
|
||
```
|
||
|
||
- **Install specific version**:
|
||
|
||
```
|
||
pip install package_name==1.2.3
|
||
```
|
||
|
||
- **Install multiple packages**:
|
||
|
||
```
|
||
pip install package1 package2
|
||
```
|
||
|
||
- **Install from requirements file**:
|
||
|
||
```bash
|
||
pip install -r requirements.txt
|
||
```
|
||
|
||
- **Upgrade a package**:
|
||
|
||
```
|
||
pip install --upgrade package_name
|
||
```
|
||
|
||
- **Uninstall a package**:
|
||
|
||
```
|
||
pip uninstall package_name
|
||
```
|
||
|
||
|
||
### Package Information
|
||
|
||
- **List installed packages**:
|
||
|
||
```
|
||
pip list
|
||
```
|
||
|
||
- **Show package details**:
|
||
|
||
```
|
||
pip show package_name
|
||
```
|
||
|
||
- **Search for packages**:
|
||
|
||
```
|
||
pip search query
|
||
```
|
||
|
||
- **Check for outdated packages**:
|
||
|
||
```
|
||
pip list --outdated
|
||
```
|
||
|
||
|
||
### Requirements Files
|
||
|
||
- **Generate requirements file from installed packages**:
|
||
|
||
```
|
||
pip freeze > requirements.txt
|
||
```
|
||
|
||
|
||
### Environment Options
|
||
|
||
- **Install to user directory**:
|
||
|
||
```
|
||
pip install --user package_name
|
||
```
|
||
|
||
- **Install without dependencies**:
|
||
|
||
```
|
||
pip install --no-deps package_name
|
||
```
|
||
|
||
- **Install from alternative index**:
|
||
|
||
```
|
||
pip install --index-url URL package_name
|
||
```
|
||
|
||
- **Install in development mode**:
|
||
|
||
```
|
||
pip install -e .
|
||
```
|
||
|
||
|
||
### Cache Management
|
||
|
||
- **Clear pip cache**:
|
||
|
||
```
|
||
pip cache purge
|
||
```
|
||
|
||
- **Show pip cache info**:
|
||
|
||
```
|
||
pip cache info
|
||
```
|
||
|
||
|
||
## pipreqs - Generate Requirements Files
|
||
|
||
Pipreqs automatically generates requirements.txt files based on imports in your project.
|
||
|
||
### Installation
|
||
|
||
```
|
||
pip install pipreqs
|
||
```
|
||
|
||
### Basic Usage
|
||
|
||
- **Generate requirements.txt in current directory**:
|
||
|
||
```
|
||
pipreqs .
|
||
```
|
||
|
||
- **Generate for specific project path**:
|
||
|
||
```
|
||
pipreqs /path/to/project
|
||
```
|
||
|
||
|
||
### Additional Options
|
||
|
||
- **Force overwrite existing requirements.txt**:
|
||
|
||
```
|
||
pipreqs --force .
|
||
```
|
||
|
||
- **Print dependencies without creating a file**:
|
||
|
||
```
|
||
pipreqs --print .
|
||
```
|
||
|
||
- **Use different filename**:
|
||
|
||
```
|
||
pipreqs --savepath requirements-dev.txt .
|
||
```
|
||
|
||
- **Exclude specific directories**:
|
||
|
||
```
|
||
pipreqs --ignore tests,docs .
|
||
```
|
||
|
||
- **Use different PyPI server**:
|
||
|
||
```
|
||
pipreqs --pypi-server URL .
|
||
```
|
||
|
||
- **Use proxy**:
|
||
|
||
```
|
||
pipreqs --proxy URL .
|
||
```
|
||
|
||
- **Debug mode**:
|
||
|
||
```
|
||
pipreqs --debug .
|
||
```
|
||
|
||
- **Get help**:
|
||
|
||
```
|
||
pipreqs --help
|
||
``` |