0
votes

virtualenv

We will activate the virtual environment first and then run pip install ... to install packages for virtual environment.

See the document, https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/

  • source env/bin/activate
  • Now that you’re in your virtual environment you can install packages. Let’s install the excellent Requests library from the Python Package Index (PyPI):

    pip install requests
    

But pipenv is different.

pipenv

As for pipenv, the instruction here, Please explain the usage of Pipfile and Pipfile.lock

Before we activate the virtual environment,

  • We could run pipenv install to install packages in the project folder first.
  • Then we can run pipenv shell to activate the virtual environment.

In other words, using virtualenv, we create/activate virtual environment first, and then pip install ... packages in virtual environment. But using pipenv, we use pipenv install ... to install packages in the project folder first and then use pipenv shell to active the environment.

Is this correct?

1

1 Answers

0
votes

Er, basically yes.

Virtualenvs change the environment in your current shell, which you can undo with deactivate, whereas pipenv shell creates a new shell that you need to exit when you have finished.