创建资源

安装使用 IBM Cloud CLI

https://console.bluemix.net/docs/cli/index.html#overview

ibmcloud api https://api.ng.bluemix.net
ibmcloud login -u [email protected] -o [email protected] -s dev

//上传
bluemix app push pythondjangotest

创建项目

django-admin startproject mysite

cd mysite
//上传程序要在这个目录执行上传命令

python3 manage.py startapp helloworld

解决依赖

pip3 freeze > requirements.txt 

chardet==2.3.0 Django==2.1.7 gunicorn==19.9.0 httplib2==0.9.2 pycurl==7.43.0 pytz==2018.9 reportbug==7.1.7 requests==2.12.4 six==1.10.0 urllib3==1.19.1 uWSGI==2.0.18

在目录下新建runtime.txt,并添加python版本 例如: python-3.6.4

遇到错误 bluemix cf set-env pythondjangotest DISABLE_COLLECTSTATIC 1 bluemix cf restage pythondjangotest

Procfile文件

web: gunicorn mysite.wsgi
bluemix app push pythondjangotest


各种问题

python3

https://console.bluemix.net/docs/runtimes/python/index.html#python_runtime

pip freeze > requirements.txt

删除requirements.txt下的不需要的依赖,否则可能报错

 Could not find a version that satisfies the requirement python-apt==1.4.0b3 (from -r /tmp/contents605391930/deps/0/requirements.txt (line 5)) (from versions: 0.0.0, 0.7.8)
          No matching distribution found for python-apt==1.4.0b3 (from -r /tmp/contents605391930/deps/0/requirements.txt (line 5))
          You are using pip version 9.0.1, however version 19.0.3 is available.
          You should consider upgrading via the 'pip install --upgrade pip' command.
          **ERROR** Could not install pip packages: Couldn't run pip: exit status 1

您可以为您的应用程序指定要使用的 Python 版本,方法是在 runtime.txt 文件中设置 python-versionnumber,该文件位于您应用程序的根目录中。例如: python-3.6.4 如果未指定版本,缺省情况下会选择 V2.7.14。

https://developer.ibm.com/tutorials/deploy-django-applications-to-ibm-cloud/

https://stackoverflow.com/questions/37318396/ibm-bluemix-cf-python-can-i-specify-pip-version

You are using pip version 9.0.1, however version 19.0.3 is available.
          You should consider upgrading via the 'pip install --upgrade pip' command.
No start command specified by buildpack or via Procfile.
   App will not start unless a command is provided at runtime.

https://stackoverflow.com/questions/30089374/what-should-the-python-start-command-look-like-in-bluemix

manifest

Procfile web: python appname.py

2019-02-27T17:30:01.02-0500 [CELL/0] ERR Failed to make TCP connection to port 8080: connection refused
   2019-02-27T17:30:01.02-0500 [CELL/0] ERR Timed out after 1m0s: health check never passed.

manifest.yml

https://bluemixstirred.wordpress.com/2014/05/29/almost-djangoing-with-bluemix/comment-page-1/

https://www.ibm.com/developerworks/cn/cloud/library/cl-worldbank-charting-app/index.html

Procfile

web: gunicorn hellodjango.wsgi –workers 3


本地安装gunicorn

sudo apt-get install python3-dev

pip3 install gunicorn sudo -H pip3 install gunicorn uwsgi

which gunicorn /usr/local/bin/gunicorn -w4 hwlpytest.wsgi


apt-get install build-essential module-assistant

https://www.linuxdashen.com/install-virtualbox-guest-additions-on-debian