简体   繁体   English

如何打包Pycharm python项目以上传到AWS Lambda?

[英]How to package a Pycharm python project for upload to AWS Lambda?

Using pycharm on Windows. 在Windows上使用pycharm。

I have created a zip file for upload to AWS Lambda the manual way: 1) Install the modules manually into a directory other than the default directory. 我已经创建了一个zip文件,用于手动上传到AWS Lambda:1)手动将模块安装到默认目录以外的目录中。 2) Create my .py code file 3) Zip the contents of the project folder 4) Upload that zip folder to Lambda 2)创建我的.py代码文件3)压缩项目文件夹的内容4)将该zip文件夹上传到Lambda

I am new to Pycharm and with a project I see that there are a whole bunch of files and folders that I do not understand. 我是Pycharm的新手,我看到有一大堆文件和文件夹,我不明白。

I tried to zip the entire Pycharm project contents and upload - that did not work. 我试图压缩整个Pycharm项目内容并上传 - 这不起作用。 It looks like I need to run some kind of setup that creates the proper folder structure and files that have the correct content. 看起来我需要运行某种设置来创建正确的文件夹结构和具有正确内容的文件。

Any help would be appreciated. 任何帮助,将不胜感激。

For all those still stuck with this, I have a few suggestions which could possibly resolve the issue altogether: 对于那些仍然坚持这一点的人,我有一些建议可以完全解决这个问题:

  • Use pip's -t option to specify the Application Directory 使用pip的 -t选项指定应用程序目录

    Using Pip's -t option, one can specify the Application directory. 使用Pip的-t选项,可以指定Application目录。 It's better than using the pycharm's package installer, as we can specify the installation directory with this. 它比使用pycharm的软件包安装程序更好,因为我们可以使用它来指定安装目录。

  • Zip the complete Application directory ( Answer's your question ) 压缩完整的应用程序目录( 答案是你的问题

    Go inside your Pycharm project directory -> select all -> Right Click -> send to compressed (zip). 进入你的Pycharm项目目录 - >全选 - >右键单击 - >发送到压缩(zip)。 This may result in the inclusion of some unneeded directories (__pycache__, .idea), but would not affect the program execution. 这可能会导致包含一些不需要的目录(__pycache __,.idea),但不会影响程序执行。 If needed, you may skip those two directories while creating the zip. 如果需要,您可以在创建zip时跳过这两个目录。

I believe you were zipping the project directory, rather than compressing the contents of the Project directory. 我相信你正在压缩项目目录,而不是压缩Project目录的内容。

As I also answered here Jetbrains now offers the AWS Toolkit which allows local and remote development of Lambda functions. 正如我在这里也回答的那样 Jetbrains现在提供了AWS Toolkit,它允许本地和远程开发Lambda函数。

Despite some lingering issues it works quite well. 尽管存在一些挥之不去的问 Still finding my way with it. 仍然找到我的方式。

It includes packaging and deploying. 它包括包装和部署。

Toolkit page on Jetbrains website Jetbrains网站上的工具包页面

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM