TypeError: __init__() got an unexpected keyword argument 'app_private_key_path'解决

^C(python3.7) appleyuchi@ubuntu19:django_alipay_insert$ python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).

You have 17 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.

March 02, 2020 - 08:46:39
Django version 2.2.10, using settings 'django_alipay_insert.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
[02/Mar/2020 08:46:44] "GET / HTTP/1.1" 200 1159
Internal Server Error: /pay/
Traceback (most recent call last):
  File "/home/appleyuchi/.virtualenvs/python3.7/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/home/appleyuchi/.virtualenvs/python3.7/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/appleyuchi/.virtualenvs/python3.7/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/appleyuchi/桌面/Django接入支付宝/django_alipay_insert/payments/views.py", line 31, in pay
    debug=True  # 默认False  配合沙箱模式使用
TypeError: __init__() got an unexpected keyword argument 'app_private_key_path'
Internal Server Error: /check_pay/
Traceback (most recent call last):
  File "/home/appleyuchi/.virtualenvs/python3.7/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/home/appleyuchi/.virtualenvs/python3.7/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/appleyuchi/.virtualenvs/python3.7/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/appleyuchi/桌面/Django接入支付宝/django_alipay_insert/payments/views.py", line 64, in check_pay
    debug=True  # 默认False  配合沙箱模式使用
TypeError: __init__() got an unexpected keyword argument 'app_private_key_path'
[02/Mar/2020 08:46:45] "POST /pay/ HTTP/1.1" 500 17458
[02/Mar/2020 08:46:45] "GET /check_pay/?order_id=2016101400682827 HTTP/1.1" 500 17370

略难解决...

(python3.7) appleyuchi@ubuntu19:~$ python -c "import alipay;print(alipay)"
<module 'alipay' from '/home/appleyuchi/.virtualenvs/python3.7/lib/python3.7/site-packages/python_alipay_sdk-2.0.1-py3.7.egg/alipay/__init__.py'>
根据[1]我们知道:

这个python蛋就是一个类似于jar的东西,里面都是二进制,那就没法打开来看,

有点难啊...怎么办呢?

最终解决方案:

>>> import inspect
>>> from alipay import AliPay
>>> inspect.getsource(AliPay)
'class AliPay(BaseAliPay):\n    pass\n'
>>> inspect.getargspec(AliPay)
__main__:1: DeprecationWarning: inspect.getargspec() is deprecated since Python 3.0, use inspect.signature() or inspect.getfullargspec()
ArgSpec(args=['self', 'appid', 'app_notify_url', 'app_private_key_string', 'alipay_public_key_string', 'sign_type', 'debug'], varargs=None, keywords=None, defaults=(None, None, 'RSA2', False))

上面加粗的就是我们需要的

Reference:

[1]https://stackoverflow.com/questions/2051192/what-is-a-python-egg

发布了717 篇原创文章 · 获赞 324 · 访问量 157万+

猜你喜欢

转载自blog.csdn.net/appleyuchi/article/details/104615154