The Python version of AWS Lambda is Python 2.7. This is a workaround memo when installing awscli and boto3 in Windows Anaconda environment and Python 2.7 environment. There are two problems to avoid.
The awscli, boto3 package for win-64 cannot be found (occurs in Windows Anaconda environment)
> conda install awscli
PackageNotFoundError: Package not found: '' Package missing in current win-64 channels:
- awscli
> conda install boto3
PackageNotFoundError: Package not found: '' Package missing in current win-64 channels:
- boto3
Unicode Warning (occurs in Python 2.7 environment) Command example
> aws s3 ls s3://<bucket_name>
Unicode Warning that occurs in Anaconda2 environment
```
Anaconda2\lib\site-packages\dateutil\parser.py:605: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
elif res.tzname and res.tzname in time.tzname:
```
Unicode Warning that occurs in the environment where AWS CLI is installed by msi
```
C:\Program Files\Amazon\AWSCLI\.\dateutil\parser.py:601: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
```
For Windows environment, specify conda-forge.
> conda install -c conda-forge awscli
For Windows environment, specify conda-forge.
> conda install -c conda-forge boto3
Anaconda3
> aws --version
aws-cli/1.10.44 Python/3.5.2 Windows/10 botocore/1.4.34
Anaconda2
> aws --version
aws-cli/1.10.44 Python/2.7.12 Windows/10 botocore/1.4.34
This is a temporary measure, but it suppresses ʻUnicode Warning`.
aws command
Anaconda2 \ Scripts \ aws.cmd Specify -W ignore :: UnicodeWarning
on line 19.
%PythonExe% -x %PythonExeFlags% "%~f0" %*
%PythonExe% -W ignore::UnicodeWarning -x %PythonExeFlags% "%~f0" %*
python command
Specify -W ignore :: UnicodeWarning
.
Example of running the Boto sample
> python -W ignore::UnicodeWarning .\s3_sample.py
IPython
Run the Unicode Warning suppression script when IPython starts.
~/.ipython/profile_default_startup
or <user_home>\.ipython\profile_default\startup
import warnings
warnings.filterwarnings('ignore', category=UnicodeWarning)
Recommended Posts