[Errno 2] No such file or directory errors when running AWS commands

0

First off, I am new to Python and AWS, but I know Windows.

When I open a command prompt and run Python, everything works fine regarding core Python commands. However, when I try to execute any AWS commands with Python I get "No such file of directory" when trying to locate AWS. See below:

C:\WINDOWS\system32>python aws configure python: can't open file 'C:\WINDOWS\system32\aws': [Errno 2] No such file or directory

I installed boto3, and the install path is: "C:\Users<User>\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\Scripts"

If I change directory (CD) to "C:\Users<User>\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\Scripts", then everything works fine.

How do I get Python to "include" the "C:\Users<User>\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\Scripts" folder, so I can run Python from other folder?

It seems like I should NOT have to change directory to "C:\Users<User>\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\Scripts" to get things working.

My OS is Windows 10.

Some of my user PATH environment variable paths are below: C:\Users<User>\AppData\Local\Programs\Python\Python311 C:\Users<User>\AppData\Local\Programs\Python\Python311\Scripts C:\Users<User>\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\Scripts

Thanks,

Kent

질문됨 2년 전1.7천회 조회
1개 답변
0

Hi Kent

In the C:\WINDOWS\system32>python aws configure python its looks for the aws command within the system32 folder and since its not present in the system32 folder it gives you the file not found error.

Other than trying to install packages at a global level I would recommend that you create Python virtual environment, activate it, then install the required packages there and try out your commands. With the virtual environment activated python will look for any installed packages within the environment.

This will allow you to have an encapsulated environment with all your required packages without having to deal with Windows PATHs or anything.

Python Documentation -> https://docs.python.org/3/library/venv.html Guide to creating virtual environments -> https://www.askpython.com/python/activating-virtual-environment-in-windows-10

Hope this helps

profile picture
답변함 2년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인