Forums

How can I change directory using commands in pythonanywhere?

I have this piece of code in my script on my Windows PC. How can I do the equivalent in PythonAnywhere? Is 'cd' even allowed in PythonAnywhere?

try:
    complete_string = "cd C:\\Users\\Raymond\\Desktop\\Chess Bot\\tensorflow_chessbot-chessfenbot && tensorflow_chessbot.py --url %s" % (url)
    r = str(subprocess.check_output(complete_string, shell=True, timeout=60))
except:
    print("No chessboard detected in image below.")
    raise AssertionError

PythonAnywhere runs on Linux, not Windows. Linux doesn't use drive labels such as C:\

smh

So the equivalent in linux would be this?

"cd \home\Raymond\Chess Bot\tensorflow_chessbot-chessfenbot && tensorflow_chessbot.py --url %s" % (url)

Your home directory's name is the same as your PA username, so it would be /home/rayorayoray instead of /home/Raymond. Also, you have to use forward slashes instead of backslashes.

Thanks for the information. Unfortunately, I still encounter some errors. So I ended up using the following command:

    try:
    complete_string = "cd /home/rayorayoray/tensorflow_chessbot-chessfenbot && ./tensorflow_chessbot.py --url %s" % (url)
    r = str(subprocess.check_output(complete_string, shell=True, timeout=60))
except:
    print("No chessboard detected in image below.")
    raise AssertionError

However, I get the following error:

/bin/sh: 1: ./tensorflow_chessbot.py: Permission denied

Do python3 ./tensorflow_chessbot.py instead of just ./tensorflow_chessbot.py. You should also specify the specific Python version like this: python3.7

How do you run your script? What command do you use? Do you specify python version as dull mentioned above?

and what about running scripts? https://myip.kim/ https://birthdaywishes.onl/ https://elecpay.in/tneb/

you could use the same command for scripts.

eg: cd /home/rayorayoray/tensorflow_chessbot-chessfenbot && ./tensorflow_chessbot.py

We do not run Windows on PythonAnywhere.