2015-10-29 35 views
0

我在OpenShift上創建了我的Rails應用程序。它使用Python和從PIP安裝的軟件包。我如何升級到較新的Python版本(目前爲2.6)?OpenShift - 在Rails應用程序中更新Python並安裝PIP

可見墨盒:

[email protected]:~$ 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. 

然後試圖安裝一個新的Python ...

[email protected]:~$ 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'. 

如果可以安裝Python的新版本,我該如何安裝PIP?

回答

0

我已經將lib複製到OpenShift中,將它包含在包含路徑中並使用py2.6執行它!問題解決了!

0

沒有名爲python的墨盒,因爲當您嘗試將墨盒添加到現有的應用程序時,它只會顯示兼容墨盒。由於注意到rhc cartridges命令:

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

用於更新Python版本的最好方法是創建一個新的應用程序,並從舊的應用程序導入代碼。

1)創建一個新的應用程序

$ rhc app create py33 python-3.3 

2)獲取git的URL,並將其作爲遠程添加到您的應用程序

$ 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 

至於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)