2020年6月13日 星期六

[note] psycopg2 無法安裝排解

在安裝套件時
sudo pip install psycopg2

安裝遭遇以下log:

    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-install-dBC6Co/psycopg2/setup.py'"'"'; __file__='"'"'/private/tmp/pip-install-dBC6Co/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base pip-egg-info
         cwd: /private/tmp/pip-install-dBC6Co/psycopg2/
    Complete output (27 lines):
    /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'project_urls'
      warnings.warn(msg)
    /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'python_requires'
      warnings.warn(msg)
    running egg_info
    creating pip-egg-info/psycopg2.egg-info
    writing pip-egg-info/psycopg2.egg-info/PKG-INFO
    writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt
    writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt
    writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt'

    Error: pg_config executable not found.

    pg_config is required to build psycopg2 from source.  Please add the directory
    containing pg_config to the $PATH or specify the full executable path with the
    option:

        python setup.py build_ext --pg-config /path/to/pg_config build ...

    or with the pg_config option in 'setup.cfg'.

    If you prefer to avoid building psycopg2 from source, please install the PyPI
    'psycopg2-binary' package instead.

    For further information please check the 'doc/src/install.rst' file (also at
    <https://www.psycopg.org/docs/install.html>).

    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

請直接安裝
sudo pip install psycopg2-binary即可解決





2019年11月21日 星期四

[note][MAC] dyld: Library not loaded 解決方式

在使用tig指令時,遇到以下問題:
----------------------------------
dyld: Library not loaded: /usr/local/opt/readline/lib/libreadline.7.dylib
  Referenced from: /usr/local/bin/tig
  Reason: image not found
Abort trap: 6
----------------------------------

版本: MAC 10.14

透過以下方式可以解決
----------------------------------
cd /usr/local/opt/readline/lib
ln -s libreadline.8.0.dylib libreadline.7.dylib
----------------------------------

2019年11月12日 星期二

[note] 在heroku平台找不到pytz套件的解決方式

在撰寫slack app時,
使用timezone套件,
----------------
import pytz
----------------
發佈至heroku時,遭遇以下log:
----------------
2019-11-12T16:34:01.371570+00:00 app[web.1]: import pytz
2019-11-12T16:34:01.371634+00:00 app[web.1]: ModuleNotFoundError: No module named 'pytz'
----------------

2019年11月11日 星期一

[note] 解決line bot 重複發送訊息兩次問題

在串接linebot with python

使用slack會發現主動傳訊息會發送兩次的狀況發生。

影響的api有

line_bot_api.push_message()
及
line_bot_api.broadcast()

只要是主動傳訊息的都會發生傳送兩次

那該如何解決呢?


2019年10月21日 星期一

[note] heroku 更改顯示時區 timezone

觀察log時常常發現 heroku 預設時間不是台灣時區

以下是更改時區的command (台灣)

2019年10月8日 星期二

[Note] ImportError: No module named pandas 排除

發現以下error時,代表有使用到pandas模組但是系統找不到此模組。

這裡紀錄在MAC OSX上安裝pandas模組的方法