Comments (9)
After further investigation, it looks like this might be able to be worked around by using a python3-only virtual env. I was hoping to avoid this in case we had a project that used both python2 and python3 functions, but in retrospect that would probably break completely anyways.
Apparently, even though I had python36 as my default python and was using the python36 runtime, aws-sam-cli was still hard-coded in my install to run under python27 and as a result was using pip2.7. Would it make more sense (or even be possible) to have the lambda-builder use the version of pip that matches the runtime version rather than the version matching sam-cli?
from aws-lambda-builders.
@jasonmk Thanks for the detailed issue!
What OS are you running on?
We are adding some improvements in this area in #55. We (SAM CLI) pick the first python in the PATH, the PR will be adding support for picking the first executable in the PATH that is validated. From SAM CLI, you can also use the --use-container
option that will run the build in a container. This will ensure the correct python version is used. It is slower but does give you another path forward. You can also muck with your PATH but I tend to just do the --use-container
until we have #55 merged and released.
from aws-lambda-builders.
This is CentOS 7. I had tried it with a container but got a different error. However, that seems to be working now so it's possible I had the same cross-contamination issue there as well.
Definitely a lot slower....
I almost wonder if it wouldn't make more sense to treat python the same as node or ruby. Don't make any assumptions about anything (first in the path or default versions etc) and specifically look up the commands for the runtime in use. That would have the advantage of also letting you combine python2 and python3 functions in the same project without using containers. (I'm actually against using python2 at all for philosophical reasons, but I'm sure people out there do it.)
from aws-lambda-builders.
#55 will get you that flexibility (authored by @TheSriram). Python was the first one written and we are heading towards a more robust way of resolving the executables across all runtimes supported.
"(I'm actually against using python2 at all for philosophical reasons, but I'm sure people out there do it.)"
But you installed SAM CLI in Py2 :(
from aws-lambda-builders.
Not on purpose. I try to always keep python3 as the default, but apparently something got messed up. I'm not a python developer by far so I get confused a lot switching around between the system default and what I'm trying to use for my projects....
from aws-lambda-builders.
I think this issue is a duplicate of #11 and #30. This both should be captured by PR #55. I am inclined to close in favor of the ones we have open.
On the installation, for linux we provide LinuxBrew as an installation mechanism. We are considering expanding this to Snap as well. Either would help in keeping you system sane and get you off Py2.
from aws-lambda-builders.
Never heard of linuxbrew. Snap wasn't CentOS compatible last I checked, but I know they're working on it.
Feel free to close if it's covered. I'll keep on eye on 55.
from aws-lambda-builders.
@jasonmk Yes #55 should help you to run build with the appropriate python executable that matches your runtime.
from aws-lambda-builders.
Closed as #55 is merged.
from aws-lambda-builders.
Related Issues (20)
- SAM build failed in sam cli using python 3.9. HOT 3
- How to make `sam` hold my SSH keys so `sam build` can download dependencies from my private repository? HOT 4
- [Announcement] Deprecating AWS Lambda Builders on python3.6 HOT 1
- Feature request: Add support for ES Modules with esbuild. HOT 4
- Feature request: Support packaging resource files with workflow HOT 7
- Add support for SourcesContent option in esbuild builds HOT 2
- Bug: UnsupportedPackageError when tests run under setuptools 66+ HOT 1
- [Announcement] .NET Core 3.1 Runtime Deprecation
- Using pip 23.1 produces invalid deployment file when package references other local packages HOT 1
- Feature request: Allow ignoring dependencies when building with python pip HOT 2
- Bug: sam build throws error with python packages installed with git+https url HOT 3
- Bug: No message from the Maven's stderr in the sam output logs HOT 1
- Feature request: Include/Exclude Interface for AWS Lambda Builders HOT 3
- Bug: SAM is failing to build python package neo4j HOT 5
- German Umlaut in Maven stdout causes SAM build to fail HOT 4
- NodejsNpmEsbuildBuilder:NpmInstall - NPM Failed: npm WARN config production Use `--omit=dev` instead HOT 3
- Can not install custom python dependency from custom git url HOT 4
- Bug: Using AWS::Serverless::LayerVersion with BuildMethod: makefile and python runtime fails to build HOT 2
- [Announcement] Upcoming Runtime Deprecations
- Bug: dnf command does not work on version of public.ecr.aws/lambda/python:3.11-x86_64 publish around 2023.12.05 16:00 UTC HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aws-lambda-builders.