Skip to content
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

Plugin Does Not Works On CircleCI #175

Closed
philographer opened this issue Apr 17, 2018 · 2 comments
Closed

Plugin Does Not Works On CircleCI #175

philographer opened this issue Apr 17, 2018 · 2 comments

Comments

@philographer
Copy link

philographer commented Apr 17, 2018

serverless-python-requirements Plugin Does not works on CircleCI

Fail Log is Here: https://circleci.com/gh/philographer/crawl-google/35
No module named pip

My CircleCI Docker Image is here: circleci/python:2.7-jessie-node-browser

Error Log

#!/bin/bash -eo pipefail
sls deploy
Serverless: Installing requirements of requirements.txt in .serverless...
 
  Error --------------------------------------------------
 
  /usr/bin/python2.7: No module named pip

 
     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.11.1
     Serverless Version:     1.26.1
 
Exited with code 1

.circleci/config.yml

# Javascript Node CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
#
version: 2
jobs:
  build:
    docker:
      # specify the version you desire here
      - image: yoohoogun114/python-node-serverless
      
      # Specify service dependencies here if necessary
      # CircleCI maintains a library of pre-built images
      # documented at https://circleci.com/docs/2.0/circleci-images/
      # - image: circleci/mongo:3.4.4

    working_directory: ~/repo

    steps:
      - checkout

      - run:
          working_directory: ~/repo/crawl-core
          name: install dependencies
          command: sudo pip install -r requirements.txt

      # run Python tests!
      - run:
          working_directory: ~/repo/crawl-core
          name: run tests
          command: python crawl/test_crawl.py

    # run Install
      - run:
          working_directory: ~/repo/crawl-core
          name: sls plugin install
          command: sls plugin install -n serverless-python-requirements

      - run: 
          working_directory: ~/repo/crawl-core
          name: sls deploy
          command: sls deploy

serverless.yml

service: crawl-google-core

frameworkVersion: ">=1.1.0 <2.0.0"

provider:
  name: aws
  region: ap-northeast-2
  runtime: python2.7
  environment:
    SERVICE_NAME: crawl-google
    DYNAMODB_TABLE: ${self:provider.environment.SERVICE_NAME}-${opt:stage, self:provider.stage}
    STAGE: ${opt:stage, self:provider.stage}
    BUCKET_NAME: ${self:provider.environment.SERVICE_NAME}-${opt:stage, self:provider.stage}
    REGION: ${self:provider.region}
  iamRoleStatements:
    - Effect: Allow
      Action:
        - dynamodb:Query
        - dynamodb:Scan
        - dynamodb:GetItem
        - dynamodb:PutItem
        - dynamodb:UpdateItem
        - dynamodb:DeleteItem
      Resource: "arn:aws:dynamodb:${opt:region, self:provider.region}:*:table/${self:provider.environment.DYNAMODB_TABLE}"
    - Effect: Allow
      Action:
        - s3:PutObject
      Resource: "arn:aws:s3:::${self:provider.environment.SERVICE_NAME}/*"

functions:
  crawl:
    handler: crawl/crawl.crawl
    timeout: 300
  
plugins:
  - serverless-python-requirements
custom:
  pythonRequirements:
    dockerizePip: 'non-linux'

resources:
  Resources:
    S3BucketCrawlMondrian:
          Type: AWS::S3::Bucket
          DeletionPolicy: Delete
          Properties:
            BucketName: ${self:provider.environment.BUCKET_NAME}

Well Note now i'm using

plugins:
  - serverless-python-requirements
custom:
  pythonRequirements:
    dockerizePip: 'non-linux'

Why /usr/bin/python2.7: No module named pip Error?

If I Try pip --version then it could print version

$ pip --version
pip 9.0.3 from /usr/local/lib/python3.6/site-packages (python 3.6)
@dschep
Copy link
Contributor

dschep commented Apr 17, 2018

It seems that your image's default python&pip are version 3.6, thus why python2.7 doesn't have pip. This plugin uses python2.7 -m pip (or whatever your runtime or pythonBin is set to) to ensure the correct version of python is used to install your dependencies.

To fix it, you need to also install pip for python2.7 in your docker image. IE, add this to your Dockerfile:

RUN apt install python-pip

@philographer
Copy link
Author

@dschep Thanks. Your Solution Works !!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants