Giter Site home page Giter Site logo

Comments (9)

jasonmk avatar jasonmk commented on August 23, 2024

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.

jfuss avatar jfuss commented on August 23, 2024

@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.

jasonmk avatar jasonmk commented on August 23, 2024

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.

jfuss avatar jfuss commented on August 23, 2024

#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.

jasonmk avatar jasonmk commented on August 23, 2024

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.

jfuss avatar jfuss commented on August 23, 2024

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.

jasonmk avatar jasonmk commented on August 23, 2024

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.

sriram-mv avatar sriram-mv commented on August 23, 2024

@jasonmk Yes #55 should help you to run build with the appropriate python executable that matches your runtime.

from aws-lambda-builders.

CoshUS avatar CoshUS commented on August 23, 2024

Closed as #55 is merged.

from aws-lambda-builders.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.