Skip to content

Python not picked up on path #100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kadrach opened this issue Nov 7, 2017 · 6 comments
Closed

Python not picked up on path #100

kadrach opened this issue Nov 7, 2017 · 6 comments

Comments

@kadrach
Copy link

kadrach commented Nov 7, 2017

which python
/home/kadrach/.pyenv/shims/python
which python3.6
/home/kadrach/.pyenv/versions/3.6.0/bin/python3.6

(these refer to the same python 3.6 installation). The pyenv shim is on path, yet the serverless plugin fails to pick it up:

Serverless: Generating requirements.txt from Pipfile...                                                    
Serverless: Installing required Python packages with undefined...                                          
                          
  Type Error ---------------------------------------------                                                 
                          
  "file" argument must be a non-empty string         
                          
     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.                   
                          
  Get Support --------------------------------------------                                                 
     Docs:          docs.serverless.com              
     Bugs:          github.com/serverless/serverless/issues                                                
     Forums:        forum.serverless.com             
     Chat:          gitter.im/serverless/serverless  
                          
  Your Environment Information -----------------------------                                               
     OS:                     linux                   
     Node Version:           8.2.0                   
     Serverless Version:     1.24.0             

I can fix this with the following directive:

custom:
  pythonRequirements:
    pythonBin: python

but isn't this just referencing the same Python it should be using by default? Should this not work out of the box?

@dschep
Copy link
Contributor

dschep commented Nov 7, 2017

Yeah, that should work out of the box. My only guess is that your PATH env var isn't exported, if you run node, what's the output of process.env.PATH?

@dschep
Copy link
Contributor

dschep commented Nov 7, 2017

Oh wait.. i see the Installing required Python packages with undefined... part now. That's not right.. could you share your serverless.yml? It should be defaulting to your runtime

@kadrach
Copy link
Author

kadrach commented Nov 8, 2017

Removed all pieces that didn't seem to affect the minimal example:

---
service:
  name: foo 

frameworkVersion: ">=1.24.0"  # Only version tested

plugins:
  - serverless-python-requirements

# custom:
  # pythonRequirements:
  #   pythonBin: python

provider:
  name: aws

functions:
  dispatch:
    handler: dispatch.handler
    runtime: python3.6

The required python is first on path, but above example only works if I uncomment the custom block.

@kadrach
Copy link
Author

kadrach commented Nov 9, 2017

This line is looking for serverless.service.provider.runtime.

The Serverless docs allow for an optional override in the function directive. This may be a misunderstanding on my part, but I assumed I can specify the runtime at function level without setting a provider-level default (given my full example runs one method in node and one in python, setting a default didn't make much sense to me).

@dschep
Copy link
Contributor

dschep commented Nov 9, 2017

Ah, yes, this plugin doesn't support per function packaging, so it uses the global provider specification, you'll have to set it for the plugin to work.

@dschep
Copy link
Contributor

dschep commented Nov 9, 2017

I could default it to python if not set tho. but then there's no guarantee that it's the right version of python.

@dschep dschep closed this as completed in fc0288d Nov 14, 2017
dschep added a commit that referenced this issue Nov 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants