Home > Software engineering >  Execute a .py under pipenv virtual enviroment via .sh file
Execute a .py under pipenv virtual enviroment via .sh file

Time:10-26

I'm developing a small discord bot. Im doing it under the pipenv virtual enviroment. I'm fairly new to programming, so I'm reading through docs, but obviously there are some things that I don't understand

The general idea is to execute a .sh that executes pipenv shell and then the .py file.

This is the structure of my run.sh file

#!bin/bash
cd ./home/.../myprojects
pipenv shell
python myfile.py

The problem is when pipenv shell is activated, it launches a subshell and it does not run any commands from that point on. I also tried creating a script on the Pipfile to print the working directory, changing python myfile.py to pipenv run my_script . But also, nothing happens until I manually input exit on the pipenv subshell.

Thank you very much!

CodePudding user response:

You can run python script from .sh file by following command.

pipenv run python myfile.py
  • Related