Как изменить путь к терминалу при запуске команды python ?Python

Программы на Python
Гость
Как изменить путь к терминалу при запуске команды python ?

Сообщение Гость »


У меня проблема в. Whenever I try to run the Python command in the terminal I get the

Код: Выделить всё

"[Errno 2] No such file or directory" error.
All my Python files are located in the same folder, and simply running the files works.
Terminal Error Message
The actual path of the file is "E:\Python Learning\Dave Gray tutorials". How do I go about changing the path in the screenshot to matching this one?
I would appreciate it if you could help me figure out what's the best way to create the proper path for future folders.
Right click on folder + Open in integrated terminal works as it gives me the correct path, but it's not desirable given that every other .py in the folder runs just fine within the default terminal.
Here's the code for the file as well:

Код: Выделить всё

import argparse

parser = argparse.ArgumentParser(
description="Provides a personal greeting."
)

parser.add_argument(
"-n", "--name", metavar="name",
required=True, help="The name of the person to greet."
)

args = parser.parse_args()

msg = f"Hello {args.name}!"
print(msg)
I tried changing the absolute path.
The program only ran when I moved the file from its folder to the one mentioned in the terminal error message.


Источник: https://stackoverflow.com/questions/781 ... pythonfile

Вернуться в «Python»