Linux command
pip-install 命令
网络
复制后可按需替换文件名、目录或参数。
常用示例
Install package
pip install [package]
Install specific version
pip install [package]==[version]
Install from requirements file
pip install -r requirements.txt
Install in editable mode
pip install -e [path]
Upgrade package
pip install --upgrade [package]
Install to user directory
pip install --user [package]
说明
pip install installs Python packages from the Python Package Index (PyPI) and other sources. It handles dependency resolution, downloading, building from source if needed, and placing packages into the target environment. Packages can be specified by name, version constraints (==, >=, ~=), requirements files, local directories, Git URLs, or wheel files. Use -e for editable installs during development, which creates a link to the source directory rather than copying files. The --user flag installs to the user site-packages directory without requiring root privileges. By default, pip resolves and installs all dependencies. Use --no-deps to skip dependency installation for tighter control. The --pre flag includes pre-release and development versions in the resolution process. Custom package indexes can be specified with -i for private registries.
参数
- -r, --requirement _file_
- Install from requirements file.
- -e, --editable _path_
- Install in editable/develop mode.
- -U, --upgrade
- Upgrade package to newest version.
- --user
- Install to user site-packages.
- --no-deps
- Don't install dependencies.
- --pre
- Include pre-release versions.
- -i, --index-url _url_
- Use custom package index.
- --extra-index-url _url_
- Additional package index.
- -t, --target _dir_
- Install to specific directory.
- --force-reinstall
- Reinstall even if up-to-date.
FAQ
What is the pip-install command used for?
pip install installs Python packages from the Python Package Index (PyPI) and other sources. It handles dependency resolution, downloading, building from source if needed, and placing packages into the target environment. Packages can be specified by name, version constraints (==, >=, ~=), requirements files, local directories, Git URLs, or wheel files. Use -e for editable installs during development, which creates a link to the source directory rather than copying files. The --user flag installs to the user site-packages directory without requiring root privileges. By default, pip resolves and installs all dependencies. Use --no-deps to skip dependency installation for tighter control. The --pre flag includes pre-release and development versions in the resolution process. Custom package indexes can be specified with -i for private registries.
How do I run a basic pip-install example?
Run `pip install [package]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -r, --requirement _file_ do in pip-install?
Install from requirements file.