Issue
I have installed my needed packages (dependencies) in the global system environment instead of my virtual environment (virtualenv) because i have used the command pip install <package-name>
outside of the virtual environment.
So i want to know how can i make a list out of them and install them in any of my virtualenvs?
Solution
This is useful in a case that anyhow you have installed some packages (dependencies) in your global system environment instead of your virtualenv, by mistake.
For example by using the command "pip install", not "pipenv install" (outside of virtual environment).
So the solution is:
In the global system environment (outside of any virtualenv), create a "requirements.txt" file from all of your installed packages:
$ pip freeze > requirements.txt
Import installed dependencies from the created "requirements.txt" file to the Pipfile by running the below command in the root that the above created file "requirements.txt" exist; but first check:
a) If Pipfile not exist:
$ pipenv install
b) If Pipfile do exist (i.e. already created virtualenv):
$ pipenv install -r requirements.txt
Then your package listing files "Pipfile" & "Pipfile.lock" would be updated and locked.
But I personally recommend that for avoiding this problem to happen, always use the command
$ pipenv install
instead of $ pip install
.
Answered By - muel Answer Checked By - Pedro (WPSolving Volunteer)