由於有些外掛模組會有相依性問題,安裝OOO以外還要再裝XXX才能用,所以在MAC OS有個簡潔的解決方式,就是用MAC Port代為安裝。
MAC Port本身也是個外掛模組,之後就可以利用它在command line安裝其他模組(port),例如Python 2.7,但這個Python路徑就跟MAC原生的Python不同了,MAC Port的會在/opt/local/bin/python,MAC原生的會在/usr/bin/python2.7。python的external library也可以用MAC port安裝,例如Beautifulsoup或PyQT,但要注意的是這些library只能在MAC port安裝的Python底下執行。
MAC Port可以安裝的套件可在這裡查詢
https://www.macports.org/ports.php
以下是指令範例
sudo port selfupdate # 更新Mac Port
sudo port upgrade outdated # 更新安裝過的所有模組(ports)
sudo port install py27-beautifulsoup4 # 安裝beautifulsoup 4.5.3
port select --list python # 列出可用的python版本
sudo port select python python27-apple # 指定Apple版本
2017-09-02
2017-08-26
[Python] 用Heroku架Python網站
嗯.....會有這個念頭是因為想作個online轉檔的網頁,但步驟有些繁雜,無法一鍵完成。
基本上就照這個網頁一步步作,就可以在Heroku上使用Django寫Python
https://devcenter.heroku.com/articles/getting-started-with-python#introduction
BUT,最討厭的就是這個BUT,還是有些眉角要處理
但是....但是我最需要的Beautifulsoup版本只有3,我要4啊啊啊!!!
陷入無以為繼的低潮中.............
基本上就照這個網頁一步步作,就可以在Heroku上使用Django寫Python
https://devcenter.heroku.com/articles/getting-started-with-python#introduction
BUT,最討厭的就是這個BUT,還是有些眉角要處理
- Python版本: Heroku預設的版本是3.6,但我是用2.7,所以要把runtime.txt改掉https://devcenter.heroku.com/articles/python-runtimes
- Python版本: 又來一次,因為我之前用MAC Port裝python和PyQT,所以python的執行路徑不是MAC原本的版本,要改回Apple版本
- port select --list python (列出可用的python版本)
- sudo port select python python27-apple (指定Apple版本)
- 安裝過程中有遇到"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啊啊啊!!!
陷入無以為繼的低潮中.............
2017-04-09
2017-03-11
訂閱:
文章 (Atom)