使用 AWS re:Post 即表示您同意 AWS re:Post 使用條款

[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 年前檢視次數 1695 次
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 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南