问题
Using aws cli with pythno 3 on Windows, always getting a warning, but the program runs well after this message.
For example:
>>> aws --version --debug
Не найдено сопоставление для расширения имени файла .py.
aws-cli/1.15.83 Python/3.6.0 Windows/7 botocore/1.10.82
(vaguely -' Cannot find association for filename extension .py')
Any idea which part of aws scripts issues this warning and how to fix it? At what part does aws use Windows call?
回答1:
As @Evgeny describes in Windows after install AWS CLI the file aws.cmd
has this line that calls the command assoc
and produces the warning:
for /f "tokens=2 delims==" %%i in ('assoc .py') do (
The command assoc .py
shows if there is an association to python files in Windows. If you don't have a python executable associated with *.py files in your main command line (no in environments of Anaconda).
You can test that opening a command line window and try to run a simple script in a folder this way:
>test.py
If you get an error and you like to remove the warning you have to make a new association for python files, with one of this options.
- By command line (as administrator)
assoc .py=py_auto_file
ftype py_auto_file="C:\Anaconda3\python.exe" "%1" %*
- By GUI changing Defaults apps
Right clic any file with extension *.py and select properties, and select a program that manage this file, for example in "C:\Anaconda3\python.exe" or change the default app.
In Windows 10 you can follow this sequence "Start menu, select Settings > Apps > Default apps"
回答2:
you have to meet the dependency with: https://www.python.org/downloads/
so that windows could have something to register file-type .py
with.
or you'd have to register .py
to open with python3.exe
(or alike).
回答3:
I managed to get feedback on a issue on Github. Basically, there is a one line change that can supress the warning.
In aws.cmd
instead of:
for /f "tokens=2 delims==" %%i in ('assoc .py') do (
use:
for /f "tokens=2 delims==" %%i in ('assoc .py 2^> nul') do (
This diverts warnings to null. There is also a pull request with this suggested change, but it was not mergerged to code unfortunately.
Anyone experiencing this problem can change a local file aws.cmd
as <your python directory>/Scripts
folder.
来源:https://stackoverflow.com/questions/51984135/aws-cli-file-extension-association-warning-on-windows