使用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 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则