9

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,467
  • 4
  • 33
  • 58
S.cll
  • 123
  • 1
  • 1
  • 6

2 Answers2

11

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

Community
  • 1
  • 1
Abdel-Raouf
  • 700
  • 1
  • 8
  • 20
2

You can activate the virtual environment then run the file

    pipenv shell
    python train.py
SAB6
  • 311
  • 2
  • 6