Search code examples
pipenv

Is it possible to create multiple pipenvs on a computer for multiple projects?


I'm learning about virtual environments in Python 3.9.2 and I learned that we can use pipenv rather than pip and venv to create virtual environments for our project. However, after some trial with different project directories I've made I have been unable to create another folder where pipenv stores packages I've downloaded, unlike pip and venv, which I can use to create an isolated virtual environment for each project and download packages into a folder in the virtual environment of each project.

When I enter pipenv --venv into the terminal in VScode it shows only one directory where the packages are stored, and when I enter pipenv install <name_of_package> it goes into that same directory, it doesn't create a new one for each project which I thought it would. This is essentially the same as downloading packages globally, since I only have one pipenv directory for my one machine.


Solution

  • I was able to solve the issue without altering any environment variables. First I downloaded and installed the most recent version of Python and then uninstalled the older version that I had previously, in my case downloading Python 3.12 and removing Python 3.9.2. I made sure to remove any files related to the older version on my computer, and then to confirm that the later version was installed I typed the following command in command prompt (using Windows): python -V. After that I used pip to install pipenv again, then I had to locate the path to python.exe and enter that as as command in command prompt. The file was hidden, so finding it was a little tricky, but the way I found it was by going into the Start menu and entering python 3.12 in the search bar. One of the results said python 3.12(64 bit); I right-clicked that result and clicked open file location, which opened the folder with the shortcut to python.exe. Then I right-clicked that shortcut and clicked File Insight, which opened a Norton Antivirus window containing some details about the file as well as a link to the location of python.exe to which the shortcut directs. When I clicked that it opened a File Explorer window showing the executable file in its parent folder and the path to it beside the search bar, so I used that path in command prompt to specify the version of Python pipenv should use, like this:

    pipenv --python path\to\python
    

    After that I had to delete the Pipfile and Pipfile.lock files that the previous version of pipenv had made for Python 3.9 by opening up File Explorer and using the search bar to find it, then using command prompt I made another folder in my user account on my computer, changed the directory of command prompt to that folder and using pipenv shell I was able to make a virtual environment for that folder. To verify that the problem was solved I made another folder and was able to make another virtual environment for that folder as well.