Linux command
pipenv 命令
网络
复制后可按需替换文件名、目录或参数。
常用示例
Create virtual environment and install packages
pipenv install [requests]
Install dev dependencies
pipenv install --dev [pytest]
Install from Pipfile
pipenv install
Activate virtual environment
pipenv shell
Run command in virtual environment
pipenv run [python script.py]
Generate requirements.txt
pipenv requirements > requirements.txt
Show dependency graph
pipenv graph
Remove virtual environment
pipenv --rm
说明
pipenv combines pip and virtualenv into a single workflow. It manages project dependencies with Pipfile/Pipfile.lock files, similar to npm's package.json or Ruby's Bundler. The Pipfile replaces requirements.txt with a more structured format. It separates production and development dependencies. The Pipfile.lock ensures deterministic builds by pinning exact versions and hashes. Virtual environments are created automatically per project. The shell command activates the environment, while run executes commands within it without manual activation. Environment location is determined by the project directory. Security features include hash verification of packages and vulnerability scanning via check command. The graph command visualizes the dependency tree, helping understand transitive dependencies. Pipenv integrates with .env files, automatically loading environment variables. This keeps secrets separate from code while making them available during development.
参数
- install _packages_
- Install packages and add to Pipfile.
- uninstall _packages_
- Remove packages from environment.
- lock
- Generate Pipfile.lock.
- sync
- Install packages from Pipfile.lock.
- shell
- Spawn shell in virtual environment.
- run _command_
- Run command in virtual environment.
- graph
- Show dependency graph.
- check
- Check for security vulnerabilities.
- requirements
- Generate requirements.txt output.
- update _packages_
- Update packages.
- clean
- Remove packages not in Pipfile.lock.
- --dev, -d
- Include dev dependencies.
- --python _VERSION_
- Specify Python version.
- --venv
- Show virtual environment path.
- --rm
- Remove virtual environment.
- --where
- Show project home.
- --three / --two
- Use Python 3 / Python 2.
- --site-packages
- Enable system site-packages.
FAQ
What is the pipenv command used for?
pipenv combines pip and virtualenv into a single workflow. It manages project dependencies with Pipfile/Pipfile.lock files, similar to npm's package.json or Ruby's Bundler. The Pipfile replaces requirements.txt with a more structured format. It separates production and development dependencies. The Pipfile.lock ensures deterministic builds by pinning exact versions and hashes. Virtual environments are created automatically per project. The shell command activates the environment, while run executes commands within it without manual activation. Environment location is determined by the project directory. Security features include hash verification of packages and vulnerability scanning via check command. The graph command visualizes the dependency tree, helping understand transitive dependencies. Pipenv integrates with .env files, automatically loading environment variables. This keeps secrets separate from code while making them available during development.
How do I run a basic pipenv example?
Run `pipenv install [requests]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does install _packages_ do in pipenv?
Install packages and add to Pipfile.