serverless-python-requirements: __pycache__ conflict

I get the following when I try to deploy

Serverless: Parsing Python requirements.txt
Serverless: Installing required Python packages for runtime python3.6...
Serverless: Linking required Python packages...
 
  Error --------------------------------------------------
 
  Unable to link dependency '__pycache__' because a file
                             by the same name exists in this service
 
     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
 
  Stack Trace --------------------------------------------
 
Error: Unable to link dependency '__pycache__' because a file
                             by the same name exists in this service
    at fse.readdirSync.map (/home/winstonewert/projects/domain-influencer-engine/node_modules/serverless-python-requirements/index.js:162:19)
    at Array.map (native)
    at ServerlessPythonRequirements.linkRequirements (/home/winstonewert/projects/domain-influencer-engine/node_modules/serverless-python-requirements/index.js:151:40)
From previous event:
    at Object.before [as hook] (/home/winstonewert/projects/domain-influencer-engine/node_modules/serverless-python-requirements/index.js:249:10)
    at BbPromise.reduce (/home/winstonewert/projects/domain-influencer-engine/node_modules/serverless/lib/classes/PluginManager.js:236:55)
From previous event:
    at PluginManager.invoke (/home/winstonewert/projects/domain-influencer-engine/node_modules/serverless/lib/classes/PluginManager.js:236:22)
    at PluginManager.spawn (/home/winstonewert/projects/domain-influencer-engine/node_modules/serverless/lib/classes/PluginManager.js:248:17)
    at Deploy.BbPromise.bind.then.then (/home/winstonewert/projects/domain-influencer-engine/node_modules/serverless/lib/plugins/deploy/deploy.js:101:50)
From previous event:
    at Object.before:deploy:deploy [as hook] (/home/winstonewert/projects/domain-influencer-engine/node_modules/serverless/lib/plugins/deploy/deploy.js:99:10)
    at BbPromise.reduce (/home/winstonewert/projects/domain-influencer-engine/node_modules/serverless/lib/classes/PluginManager.js:236:55)
From previous event:
    at PluginManager.invoke (/home/winstonewert/projects/domain-influencer-engine/node_modules/serverless/lib/classes/PluginManager.js:236:22)
    at PluginManager.run (/home/winstonewert/projects/domain-influencer-engine/node_modules/serverless/lib/classes/PluginManager.js:255:17)
    at variables.populateService.then (/home/winstonewert/projects/domain-influencer-engine/node_modules/serverless/lib/Serverless.js:99:33)
    at runCallback (timers.js:781:20)
    at tryOnImmediate (timers.js:743:5)
    at processImmediate [as _immediateCallback] (timers.js:714:5)
From previous event:
    at Serverless.run (/home/winstonewert/projects/domain-influencer-engine/node_modules/serverless/lib/Serverless.js:86:74)
    at serverless.init.then (/home/winstonewert/projects/domain-influencer-engine/node_modules/serverless/bin/serverless:39:50)
    at <anonymous>
 
  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.1
     Serverless Version:     1.19.0

The situation is caused by both .requirements and my folder containing a pycache folder.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 10
  • Comments: 21

Most upvoted comments

I just tried rm -rf __pycache__ before sls deploy and it fixed the problem, thanx ! That workaround is fine with me but wasn’t clear to me when reading the issue comment log. It may be interesting to mention it in the documentation because AFAIU anybody using Python 3.6 is affected by it.

Yes, pyc is cross platform (but not compatible between versions of python). I think we’d hurt performance quite a bit by not including compiled .pyc files.

On Wed, Aug 16, 2017 at 12:15 PM Daniel Schep notifications@github.com wrote:

Does a pyc made with a Mac OS, or say 32bit linux distro, work on Amazon linux(thus lambda)?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/UnitedIncome/serverless-python-requirements/issues/54#issuecomment-322871412, or mute the thread https://github.com/notifications/unsubscribe-auth/AA0Zfe1qwDOOkKryL-mN24ab-sJjt_z2ks5sYz-_gaJpZM4O2sS5 .

If we want to go down that route, perhaps we should pass ‘–no-compile’ to pip instead to prevent generating the pycache folder in the first case…

Yes, it’s fixed by commit f06b445 as github indicates. It was released in v3.1.1

Don’t be ! Your plugin is awesome