pipenv
pipenv copied to clipboard
"pipenv install" is unclear to me
It is unclear to me what the purpose of pipenv install
is.
Usually I do install packages via pip
in a virtual environment. So what is the advantage of pipenv install
?
StackOverflow would be a better place to post a support-type question like this, but in a nutshell, pipenv install
, when used by itself, creates a new venv if none exists and then installs into the venv everything found in Pipfile
. If a specific package is named (pipenv install package_name
), then it installs that package into the venv (and starts by creating the venv if it doesn't already exist). Install also creates or updates Pipfile.lock.
StackOverflow would be a better place to post a support-type question like this
Such answer feels a bit inpolite from my point of view.
Then why do you offer a "Usage / Requests for Help" section in your Issues?
From maintainer to maintainer: Youcould treat question from your users as an opportunity to improve your docu or the way/path to the docu.
If a specific package is named (
pipenv install package_name
), then it installs that package into the venv (and starts by creating the venv if it doesn't already exist)
In this case it would be a short form of this?
pipenv shell
pip install mypackage
@buhtz Just a pipenv user here, not a maintainer. I certainly didn't mean to be impolite and didn't mean that your question was a bad one, so I'm sorry that my answer sounded brusque. I was just suggesting StackOverflow because your question would then be there permanently for anyone to see vs being in an issue here that will be closed at some point and might not be as easily discovered. I agree that the docs could use a bit of improvement, but I know that the primary maintainer is doing his best to keep up with the issues here (I just submitted one myself a few days ago), and so I doubt if he's had time to also update the docs. Overall, I've used pipenv
for years and have been very happy with it.
To answer your last question there: You would do pipenv install mypackage
BEFORE doing pipenv shell
. pipenv shell
activates the virtual environment. You never use pip
along with pipenv
other than to do pip install pipenv
to initially install pipenv
on your machine (or pip install --upgrade pipenv
to upgrade).
You never use
pip
along withpipenv
other than to dopip install pipenv
to initially installpipenv
on your machine (orpip install --upgrade pipenv
to upgrade).
But I do use pip inside the environment and couldn't discover a problem yet. So when I can not use pip then why should I use a virtual environment. Now I am totally confused and maybe misinterpret the purpose of pipenv.
In general, I like the summary that https://search.brave.com provides when I do a search, so this information might be useful.
Pipenv is virtual Environment management tool which automatically creates and manages a virtual environment for your projects, as well as adds and removes dependencies.
When you run pipenv install, it not only installs the specified package but also creates a Pipfile and Pipfile.lock to manage project dependencies. This helps in ensuring consistent and reproducible environments for your projects.
Where to Use pipenv and pip
*** Large Team Collaboration****
Using pipenv: Suppose you're part of a large development team working on a complex project. With pipenv, you can easily share and replicate the project's environment using the Pipfile and Pipfile.lock, ensuring that everyone works with the same package versions.
Using pip: In a large team setting, if the team has a well-established process for virtual environment management and dependency tracking, using pip in conjunction with a requirements.txt file might be the preferred approach.
Iam new to this platform and opensource contributions ,If there are any mistakes please teach me i will eventually learn .... :)
Are there plans to support pyproject.toml?
The point is I do not use pipfile and I do not need to create or manage a virtual env. What I like on pipenv is that it creates a virtual env and open it in a sub-shell. Managing dependencies should not be its concern. There is pip and the pyproject.toml for that. I open the environment via "pipenv shell" and then just do "python3 -m pip install ." and everything is fine. This is also reproducible for other project members.
The way you use pipenv
seems to be more in line with either venv
or virtualenv
. Have you given them a shot?
Yes, I gave them a shot. But they do not open a sub-shell.
If you really need a subshell and support for installing dependencies from pyproject.toml perhaps hatch will help you.
What is pipenv
and pipenv install
?
Purpose of pipenv install
:
-
pipenv
is a tool that helps you manage your Python project's dependencies and environment. - When you run
pipenv install
, it sets up a virtual environment for your project and installs the required packages.
Advantages of pipenv install
over pip
in a virtual environment:
-
Dependency Management:
-
Purpose: With
pipenv
, you declare your project's dependencies in a simple file. - Advantages: This ensures everyone working on the project uses the same packages, making collaboration smoother.
- Docs: Pipenv Basics
-
Purpose: With
-
Virtual Environment Magic:
-
Purpose:
pipenv
automatically creates and manages a virtual environment for your project. - Advantages: No worries about clashes with system-wide Python or different project requirements.
- Docs: Pipenv Features
-
Purpose:
-
Automatic Activation:
-
Purpose:
pipenv
activates your virtual environment when you enter your project. - Advantages: It's always on when you need it, and off when you don't, preventing accidental global installations.
- Docs: Pipenv Basics
-
Purpose:
-
Dependency Locking:
-
Purpose:
pipenv
locks down specific versions of your dependencies. - Advantages: Ensures everyone uses the same package versions, reducing "it works on my machine" issues.
- Docs: Pipenv Features
-
Purpose:
-
Simplified Workflow:
-
Purpose:
pipenv
combines package management and virtual environments in one. - Advantages: Easier commands and less setup, making your development workflow smoother.
- Docs: Pipenv Basics
-
Purpose:
It's like a friendly assistant that takes care of your project's needs.
Thanks for this explanation. I am sorry but I disagree in some points.
Dependency Management:
- Purpose: With
pipenv
, you declare your project's dependencies in a simple file.
This is IMHO a disadvantage. It is a redundant feature because Pythons build environment can handle that via pyproject.toml file itself. Having another file with such information is redundant and can introduce bugs.
Simplified Workflow:
- Purpose:
pipenv
combines package management and virtual environments in one.
As you can see in my case this "combination" is a problem. I am not interested in package management and I do not need it because Python itself does provide it. I only need virtual environment features; e.g. the automatic activation when entering the folder and things like this.