在Amazon Elastic Beanstalk上安装Anaconda [英] Installing Anaconda on Amazon Elastic Beanstalk

查看:80
本文介绍了在Amazon Elastic Beanstalk上安装Anaconda的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在我的Elastic Beanstalk部署中添加了部署命令,该命令下载了Anaconda安装程序,并将其安装到 / anaconda 中。一切正常,但是我无法正确修改实例的PATH,以使其包含Anaconda安装页面所建议的 / anaconda / bin 。如果我通过SSH进入实例并手动添加实例,则一切正常。但这显然不是正确的方法,因为机器将由EB自动添加。

I've added deploy commands to my Elastic Beanstalk deployment which download the Anaconda installer, and install it into /anaconda. Everything goes well, but I cannot seem to correctly modify the PATH of my instance to include /anaconda/bin as suggested by the Anaconda installation page. If I SSH into an instance and manually add it, everything works fine. But this is obviously not the correct approach, as machines will be added automatically by EB.

所以我的问题是:如何在脚本中使用Anaconda?

更多细节:


  • 我尝试添加 / anaconda / bin 我能想到的所有方法。部署前/部署脚本,自定义环境变量等。看来,无论我做什么,修改都不会在应用程序运行时持久存在。

  • 我试图通过将Anaconda添加到sys.path中来添加它: sys.path.append('/ anaconda / bin')

    无济于事。使用以下命令: sys.path.append('/ anaconda / lib / python2.7 / site-packages')允许我导入一些软件包,但在<$ c上失败$ c>导入熊猫。奇怪的是,如果我通过SSH进入实例并使用其python( /opt/python/run/venv/bin/python2.7 )运行应用程序,它将运行良好。我要疯了吗?通过EB运行时,为什么它在特定的导入语句上失败?

  • I've tried adding /anaconda/bin to the system PATH all ways I can think of. Pre/post deploy scripts, custom environment variables, etc. It seems that no matter what I do, the modifications don't persist to when the application is run.
  • I've tried to include Anaconda via adding it to sys.path: sys.path.append('/anaconda/bin')
    to no avail. Using the following: sys.path.append('/anaconda/lib/python2.7/site-packages') allows me to import some packages but fails on import pandas. Strangely enough, if I SSH into the instance and run the application with their python (/opt/python/run/venv/bin/python2.7) it runs fine. Am I going crazy? Why does it fail on a specific import statement when run via EB?

推荐答案

找到了答案: import pandas 失败,因为 matplotlib 初始化失败,因为它试图获取当前用户的主目录。由于应用程序是通过WSGI运行的,因此HOME变量设置为 / home / wsgi ,但该目录不存在。因此,通过部署命令创建此目录可解决此问题。



在Elastic Beanstalk上使用Anaconda的总体设置如下:

.ebextensions / options.config 包含:

Found the answer: import pandas was failing because matplotlib was failing to initialize, because it was trying to get the current user's home directory. Since the application is run via WSGI, the HOME variable is set to /home/wsgi but this directory doesn't exist. So, creating this directory via deployment command fixed this issue.


My overall setup to use Anaconda on Elastic Beanstalk is as follows:
.ebextensions/options.config contains:


命令:

    00_download_conda:

   命令:'wget http://repo.continuum.io/archive/Anaconda-2.0.1-Linux-x86_64.sh '

     test:测试! -d / anaconda

   01_install_conda:

    命令:'bash Anaconda-2.0.1-Linux-x86_64.sh -b- f -p / anaconda'

     test:测试! -d / anaconda

   02_create_home:

    命令:'mkdir -p / home / wsgi'

commands:
  00_download_conda:
    command: 'wget http://repo.continuum.io/archive/Anaconda-2.0.1-Linux-x86_64.sh'
    test: test ! -d /anaconda
  01_install_conda:
    command: 'bash Anaconda-2.0.1-Linux-x86_64.sh -b -f -p /anaconda'
    test: test ! -d /anaconda
  02_create_home:
    command: 'mkdir -p /home/wsgi'

00_download_conda 只需下载Anaconda。有关最新的Anaconda版本下载链接,请参见此处 test 命令是EB的一种让您仅在测试失败时才执行命令的方法...只是在开发时防止双重下载。

01_install_conda 使用选项 -b -f -p / anaconda 安装Anaconda,从而可以将其安装在指定目录中,而无需用户输入,并跳过安装(如果已安装)。

02_create_home 创建丢失的目录。

00_download_conda simply downloads Anaconda. See here for latest Anaconda version download link. The test commands are EB's way of letting you only execute the command if the test fails...Just prevents double downloading when in development.
01_install_conda installs Anaconda with options -b -f -p /anaconda which allows it to be installed in the specified directory, without user input, and skips installation if it has already been installed.
02_create_home creates the missing directory.

最后-在Python应用程序中使用Anaconda: sys.path.append('/ anaconda / lib / python2.7 / site-包)

干杯!

And finally - to use Anaconda inside your python application: sys.path.append('/anaconda/lib/python2.7/site-packages')
Cheers!

这篇关于在Amazon Elastic Beanstalk上安装Anaconda的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆