Issue
In my project folder, which I initiated pipenv shell
. When in that folder and not in the pipenv virtual enviroment. I can use the command pipenv run script.py
and it works. However, when I change directory and move outside that project folder like so pipenv run projectfolder/script.py
it fails with module error. Is there a way to run this script outside of the project folder?
Solution
You can either activate your virtual environment using pipenv shell
and then run your script like normal, e.g. python script.py
from within your project directory or python projectfolder/script.py
.
Or if you are intent on using pipenv run
, you can use the PIPFILE
setting to set the path to your Pipfile
. For example, PIPENV_PIPFILE=projectfolder/Pipfile pipenv run python projectfolder/script.py
.
Answered By - D Malan Answer Checked By - Marie Seifert (WPSolving Admin)