本文介绍了如何在GAE Python中使用不同版本的PyCrypto的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我下载了PyCrypto的实验版本( pycrypto-2.7a1.tar.gz ) 。我已将Crypto目录(从pycrypto-2.7a1.tar.gz中提取)复制到我的项目文件夹中。 在app.yaml文件中: 库: - name:pycrypto version:2.7#latest 我得到错误(当时如果我尝试在app.yaml中为PyCrypto提供2.7a1或2.7版本的版本: appcfg.py:error :解析C:\gaurav\coding\python\x\x\app.yaml时出错:不支持使用2.3,2.6或latest之一的pycrypto版本2.7 (仅限开发人员推荐的最新)在C:\gaurav\coding\python\x\x\app.yaml第73行第1列中为。 如何在app.yaml中提供正确的PyCrypto版本? 使用 app.yaml 文件告诉App Engine哪个您只希望第三方使用 的库和版本-party库在平台上。 在你的情况下,你想使用一个不可用的库的版本,所以你不能使用该方法进行配置。 除此之外,您可以按照 下载库并在GAE应用程序目录中解压缩。在此示例中,目标目录称为 pycrypto26 。 要包含类似的库的路径 一个完整的工作示例是 import webapp2 导入日志 导入sys 导入os sys.path.insert(0,os.path.join(os.path.dirname(__ file__), 'pycrypto26 / lib')) 从Crypto.Hash导入Crypto 导入SHA256,SHA512 class MainPage(webapp2.RequestHandler): def get(self): logging.info(运行PyCrypto with ver sion%s%Crypto .__ version__) self.response.write('< html>< body>') self.response.write(SHA256.new('abcd').hexdigest ()+< br>) self.response.write(SHA512.new('abcd').hexdigest()+< br>) self.response.write '< / body>< / html>') application = webapp2.WSGIApplication([('/',MainPage),],debug = True) I downloaded the experimental version of PyCrypto (pycrypto-2.7a1.tar.gz). I have copied the "Crypto" directory (extracted from pycrypto-2.7a1.tar.gz) to my project folder.In app.yaml file:libraries:- name: pycrypto version: 2.7 # latestI get error (at the time of deployment) if I try to give version as 2.7a1 or 2.7 for PyCrypto in app.yaml:appcfg.py: error: Error parsing C:\gaurav\coding\python\x\x\app.yaml: pycrypto version "2.7" is not supported, use one of: "2.3", "2.6" or "latest" ("latest" recommended for development only) in "C:\gaurav\coding\python\x\x\app.yaml", line 73, column 1.How do I provide the correct PyCrypto version in app.yaml ? 解决方案 You use the app.yaml file to tell App Engine which libraries and versions you want to use only for those Third-party libraries available at the platform.In your case, you want to use a version of the library that is not available, so you can't use that method to configure it.Instead of that, you can upload to App Engine the libraries you want to use by following the method outlined in this other question:To download the library and unzipped inside your GAE application directory. In this example, the destination directory is called pycrypto26.To include the path to that library with something likeTo import the relevant modulesA full working example isimport webapp2import loggingimport sysimport ossys.path.insert(0, os.path.join(os.path.dirname(__file__), 'pycrypto26/lib'))import Cryptofrom Crypto.Hash import SHA256, SHA512class MainPage(webapp2.RequestHandler): def get(self): logging.info("Running PyCrypto with version %s" % Crypto.__version__) self.response.write('<html><body>') self.response.write( SHA256.new('abcd').hexdigest() + "<br>" ) self.response.write( SHA512.new('abcd').hexdigest() + "<br>") self.response.write('</body></html>')application = webapp2.WSGIApplication([ ('/', MainPage),], debug=True) 这篇关于如何在GAE Python中使用不同版本的PyCrypto的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 07-18 14:04