2017-08-26

[Python] 用Heroku架Python網站

嗯.....會有這個念頭是因為想作個online轉檔的網頁,但步驟有些繁雜,無法一鍵完成。

基本上就照這個網頁一步步作,就可以在Heroku上使用Django寫Python
https://devcenter.heroku.com/articles/getting-started-with-python#introduction

BUT,最討厭的就是這個BUT,還是有些眉角要處理

  1. Python版本: Heroku預設的版本是3.6,但我是用2.7,所以要把runtime.txt改掉https://devcenter.heroku.com/articles/python-runtimes
  2. Python版本: 又來一次,因為我之前用MAC Port裝python和PyQT,所以python的執行路徑不是MAC原本的版本,要改回Apple版本
    • port select --list python (列出可用的python版本)
    • sudo port select python python27-apple (指定Apple版本)
  3. 安裝過程中有遇到"python setup.py egg_info" failed with error code 1,後來參考這個網頁https://github.com/facebookincubator/prophet/issues/140,安裝了"pip install pystan",但不知道是Python版本改過還是裝了這個才解決了問題。
最後,開啟local server是最重要的,在自己電腦上debug比較方便,照ReadMe.md的作法即可,但要先確定Postgres已經安裝好且執行了
```sh
$ git clone git@github.com:heroku/python-getting-started.git
$ cd python-getting-started
$ pip install -r requirements.txt
$ createdb python_getting_started
$ python manage.py migrate
$ python manage.py collectstatic
$ heroku local
```
Your app should now be running on [localhost:5000](http://localhost:5000/).

但是....但是我最需要的Beautifulsoup版本只有3,我要4啊啊啊!!!
陷入無以為繼的低潮中............. 

沒有留言:

張貼留言