I installed pip by downloading virtualenv
, and creating a bootstrap virtualenv, as described in this answer.
Now I want to try out pipenv
, so I used my bootstrap virtualenv to create a new virtualenv and then ran pip install pipenv
. Now I can use pipenv
, but it sees that it's already running in a virtualenv and doesn't create a new one.
How can I get pipenv
to create a new virtualenv so I can have separate virtualenvs for each project? I tried pipenv install -h
, but none of the options look promising.
It looks like pipenv has gotten smarter about this situation. Here's what worked for me. First, I installed a bootstrap environment following virtualenv's installation documentation to use it locally from source. That way, I don't need to touch the system Python, and I can install pipenv in the bootstrap environment:
$ curl --location --output virtualenv.tar.gz https://github.com/pypa/virtualenv/tarball/16.1.0
$ tar -xzf virtualenv.tar.gz
$ python pypa-virtualenv-4ad2742/src/virtualenv.py vbootstrap
$ rm -r virtualenv.tar.gz pypa-virtualenv-4ad2742/
$ vbootstrap/bin/pip install pipenv
Then I created a new project folder, and used pipenv to install numpy:
$ mkdir my_project
$ cd my_project
$ ../vbootstrap/bin/pipenv install numpy
Creating a virtualenv for this project...
Pipfile: /home/vagrant/my_project/Pipfile
Using /home/vagrant/vbootstrap/bin/python (2.7.15rc1) to create virtualenv...
ā Complete
Already using interpreter /home/vagrant/vbootstrap/bin/python
Using real prefix '/usr'
New python executable in /home/vagrant/.local/share/virtualenvs/my_project-KmT425B_/bin/python
Installing setuptools, pip, wheel...
done.
Virtualenv location: /home/vagrant/.local/share/virtualenvs/my_project-KmT425B_
Creating a Pipfile for this project...
Installing numpy...
Adding numpy to Pipfile's [packages]...
ā Installation Succeeded
Pipfile.lock not found, creating...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
ā Success!
Updated Pipfile.lock (57a39c)!
Installing dependencies from Pipfile.lock (57a39c)...
š āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā 1/1 ā 00:00:00
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
To make it easier to use, I created a symbolic link:
$ ln -s ~/vbootstrap/bin/pipenv ~/pipenv
$ ~/pipenv shell
Launching subshell in virtual environment...
vagrant@vagrant:~/my_project$ . /home/vagrant/.local/share/virtualenvs/my_project-KmT425B_/bin/activate
(my_project) $