12

Using pipenv to create a virtual environment in a folder. However, the environment seems to be in the path:

/Users/....../.local/share/virtualenvs/......

And when I run the command pipenv run python train.py, I get the error:

can't open file 'train.py': [Errno 2] No such file or directory

How to run a file in the folder where I created the virtual environment?

Omar Ali
8,6274 gold badges35 silver badges58 bronze badges
asked Nov 15, 2018 at 15:28
1
  • you can verify the location of your environment using the command: pipenv --where Commented Jun 11, 2020 at 10:50

2 Answers 2

13

You need to be in the same directory of the file you want to run then use: pipenv run python train.py

Note:

You may be at the project main directory while the file you need to run is inside a directory inside your project directory

If you use django to create your project, it will create two folders inside each other with the same name so as a best practice change the top directory name to 'yourname-project' then inside the directory 'yourname' run the pipenv run python train.py command

answered Nov 25, 2018 at 18:44
Sign up to request clarification or add additional context in comments.

Comments

2

You can activate the virtual environment then run the file

 pipenv shell
 python train.py
answered Mar 17, 2021 at 10:02

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.