简体   繁体   English

OpenShift-更新Python并在Rails应用中安装PIP

[英]OpenShift - Update Python and Install PIP in a Rails app

I have created my Rails app on OpenShift. 我已经在OpenShift上创建了我的Rails应用程序。 It uses Python and a package installed from PIP. 它使用Python和从PIP安装的软件包。 How do I upgrade to a newer Python version (currently it is 2.6) ? 如何升级到较新的Python版本(当前为2.6)?

Visible cartridges: 可见墨盒:

user@debian:~$ rhc cartridges
jbossas-7                JBoss Application Server 7              web
jboss-dv-6.1.0 (!)       JBoss Data Virtualization 6             web
jbosseap-6 (*)           JBoss Enterprise Application Platform 6 web
jboss-unified-push-1 (!) JBoss Unified Push Server 1.0.0.Beta1   web
jboss-unified-push-2 (!) JBoss Unified Push Server 1.0.0.Beta2   web
jenkins-1                Jenkins Server                          web
nodejs-0.10              Node.js 0.10                            web
perl-5.10                Perl 5.10                               web
php-5.3                  PHP 5.3                                 web
php-5.4                  PHP 5.4                                 web
zend-6.1                 PHP 5.4 with Zend Server 6.1            web
python-2.6               Python 2.6                              web
python-2.7               Python 2.7                              web
python-3.3               Python 3.3                              web
ruby-1.8                 Ruby 1.8                                web
ruby-1.9                 Ruby 1.9                                web
ruby-2.0                 Ruby 2.0                                web
jbossews-1.0             Tomcat 6 (JBoss EWS 1.0)                web
jbossews-2.0             Tomcat 7 (JBoss EWS 2.0)                web
jboss-vertx-2.1 (!)      Vert.x 2.1                              web
jboss-wildfly-8 (!)      WildFly Application Server 8.2.1.Final  web
jboss-wildfly-9 (!)      WildFly Application Server 9            web
diy-0.1                  Do-It-Yourself 0.1                      web
cron-1.4                 Cron 1.4                                addon
jenkins-client-1         Jenkins Client                          addon
mongodb-2.4              MongoDB 2.4                             addon
mysql-5.1                MySQL 5.1                               addon
mysql-5.5                MySQL 5.5                               addon
phpmyadmin-4             phpMyAdmin 4.0                          addon
postgresql-8.4           PostgreSQL 8.4                          addon
postgresql-9.2           PostgreSQL 9.2                          addon
rockmongo-1.1            RockMongo 1.1                           addon
switchyard-0             SwitchYard 0.8.0                        addon
haproxy-1.4              Web Load Balancer                       addon

Note: Web cartridges can only be added to new applications.

(*) denotes a cartridge with additional usage costs.

(!) denotes a cartridge that will not receive automatic security updates.

And then trying to install a newer Python ... 然后尝试安装更新的Python ...

user@debian:~$ rhc add-cartridge --app myappname python-3.3
Short Name       Full name
==========       =========
cron-1.4         Cron 1.4
jenkins-client-1 Jenkins Client
mongodb-2.4      MongoDB 2.4
mysql-5.1        MySQL 5.1
mysql-5.5        MySQL 5.5
phpmyadmin-4     phpMyAdmin 4.0
postgresql-8.4   PostgreSQL 8.4
postgresql-9.2   PostgreSQL 9.2
rockmongo-1.1    RockMongo 1.1
switchyard-0     SwitchYard 0.8.0
haproxy-1.4      Web Load Balancer

There are no cartridges that match 'python-3.3'.

If it's possible to install a newer version of Python, how do I install PIP? 如果可以安装更新版本的Python,如何安装PIP?

There are no cartridges named python because when you try to add a cartridge to an existing app it will only show you the compatible cartridges. 没有名为python的墨盒,因为当您尝试将墨盒添加到现有应用程序时,它只会向您显示兼容的墨盒。 As noted by the rhc cartridges command: rhc cartridges命令所述:

Note: Web cartridges can only be added to *new* applications.

The best way for updating the python version is to create a new app and import the code from your old app. 更新python版本的最佳方法是创建一个新应用,并从旧应用中导入代码。

1) Create a new app 1)创建一个新应用

$ rhc app create py33 python-3.3

2) Fetch the git url and add it as remote to your app 2)获取git网址并将其添加为您的应用程序的远程目录

$ cd old_python_app
$ git remote add py33 ssh://py33-giturl
$ git push py33 master -f 
# Force push as the repo comes with default config files

As for pip , it comes preinstalled with openshift. 至于pip ,它预装了openshift。

$ rhc ssh py33
$ pip --version
  pip 7.1.2 from /var/lib/openshift/.../python/virtenv/venv/lib/python3.3/site-packages (python 3.3)

I've copied the lib to OpenShift, included it in the include path and executed it with py2.6! 我已经将lib复制到OpenShift,将其包含在include路径中,并使用py2.6执行了它! Problem solved! 问题解决了!

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

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