#๐Ÿ”’ How do I make a Python file using a virtual environment run on computer startup?

26 messages ยท Page 1 of 1 (latest)

static talon
#

Sorry if this is the wrong place to ask but I couldn't find a much better one... I have a Discord bot that I want to run on startup of my computer. I use PyCharm so it has a venv. I've tried task scheduler and shell:startup (both a shortcut and a batch file) but neither works. Does anyone know how I can do this? Any and all help appreciated ๐Ÿ˜Š

alpine sirenBOT
#

@static talon

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

static talon
#

Please ping me when replying so I see it quicker!

livid star
#

Why doesn't the batch file work?

static talon
#

why? idk I run the batch file nothing happens

static talon
livid star
static talon
#

sure I'll try

livid star
#

you might need to cd into the venv directory as well

static talon
thick fossil
#

do not cd into the venv itself, cd into the project root

static talon
#

oh hang on

#

might be a problem with the python file, I just barely managed to see the word "traceback" before the batch file closed itself

#

but that's very strange because running it from pycharm works fine

thick fossil
#

add pause to the end of the bat

in case you're restarting each time you test, remember that you can just run the bat directly for testing before you set it to run on startup

static talon
thick fossil
#

yeah definitely a working directory issue

static talon
#

the file is there... why does it not work?

thick fossil
#

python looks for files relative to your current working directory, not relative to the file you're running

#

aka you have to cd into the right folder before running it

static talon
#

oh yay, that worked

#

very sorry, I really thought it wasn't a problem with the file...

#

but thank you so so much for the help! ๐Ÿ˜„

#

!close

alpine sirenBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.