小编Fil*_*ano的帖子

Python Social Auth NotAllowedToDisconnect at/disconnect/facebook/1 /

我正在尝试在Django应用程序中使用Python Social Auth注销,但我得到了

NotAllowedToDisconnect at /disconnect/facebook/1/
Run Code Online (Sandbox Code Playgroud)

这些是我的设置:

SOCIAL_AUTH_PIPELINE = (
    'social.pipeline.social_auth.social_details',
    'social.pipeline.social_auth.social_uid',
    'social.pipeline.social_auth.auth_allowed',
    'social.pipeline.social_auth.social_user',
    'social.pipeline.user.get_username',
    'social.pipeline.mail.mail_validation',
    'social.pipeline.user.create_user',
    'social.pipeline.social_auth.associate_user',
    'social.pipeline.social_auth.load_extra_data',
    'social.pipeline.user.user_details'
)



SOCIAL_AUTH_DISCONNECT_PIPELINE = (
    'social.pipeline.disconnect.allowed_to_disconnect',
    'social.pipeline.disconnect.get_entries',
    'social.pipeline.disconnect.revoke_tokens',
    'social.pipeline.disconnect.disconnect'
)
Run Code Online (Sandbox Code Playgroud)

这是我在模板上使用的代码

{{ assoc.provider }} (<a href="{% url 'social:disconnect_individual' assoc.provider assoc.id %}" class="disconnect">Disconnect </a>)
Run Code Online (Sandbox Code Playgroud)

python django facebook

5
推荐指数
1
解决办法
4116
查看次数

TypeError:replace()在更改时区时不使用关键字参数

我正在尝试将UTC的时区更改为America/Sao Paulo,但我收到此错误:

TypeError: replace() takes no keyword arguments
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

import pytz

local_tz = pytz.timezone('America/Sao_Paulo')
local_dt = candles[0]['time'].replace(tzinfo=pytz.utc).astimezone(local_tz)
Run Code Online (Sandbox Code Playgroud)

蜡烛时间是:

>>> candles[0]['time']
u'2017-08-03T00:03:00.000000Z'
Run Code Online (Sandbox Code Playgroud)

我怎样才能解决这个问题?

python python-2.7

5
推荐指数
1
解决办法
1万
查看次数

去除特定路由的Csrf验证

我正在尝试使用我的 Laravel 应用程序创建一个 api,但是当我对路由发出 post 请求时,Laravel 默认情况下会尝试验证 csrf 令牌。所以,我想删除 api 路由的这个验证。我想维护前端请求的验证。但是当我在 app/Http/Middleware/VerifyCsrfToken.php 中添加异常路由时,我收到了这个错误:

block_exception clear_fix
Run Code Online (Sandbox Code Playgroud)

这是VerifyCsrfToken.php

<?php

namespace App\Http\Middleware;

use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;

class VerifyCsrfToken extends BaseVerifier
{
    /**
     * The URIs that should be excluded from CSRF verification.
     *
     * @var array
     */
    protected $except = [
        //
        'log_bounces_complaints',
    ];
}
Run Code Online (Sandbox Code Playgroud)

php laravel laravel-5

4
推荐指数
1
解决办法
1275
查看次数

命令'cc'在OSX High Sierra上以退出状态1失败

我正试图在Mac Os高山上运行

pip install MySQL-python
Run Code Online (Sandbox Code Playgroud)

但我得到了

error: command 'cc' failed with exit status 1
Run Code Online (Sandbox Code Playgroud)

我已经尝试过关于这个主题的解决方案,但它没有用.

这是完整的错误消息

The directory '/Users/filipeferminiano/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/filipeferminiano/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the …
Run Code Online (Sandbox Code Playgroud)

python macos mysql-python python-2.7

4
推荐指数
2
解决办法
4768
查看次数

在Model.belongsTo上调用的东西不是Sequelize.Model的实例

我正在尝试在两个模型之间引用外键.

但我收到这个错误:

throw new Error(this.name + '.' + Utils.lowercaseFirst(Type.toString()) + ' called with something that\'s not an instance of Sequelize.Model');
called with something that's not an instance of Sequelize.Model
    at Model.belongsTo
Run Code Online (Sandbox Code Playgroud)

我怎样才能解决这个问题?

到目前为止这是我的代码.

这是我的模特/ mercadolibre.js

"use strict";
var User  = require('../models/index').User;

module.exports = function(sequelize, DataTypes) {
  var MercadoLibre = sequelize.define("MercadoLibre", {
    id:  { 
          type: DataTypes.INTEGER, 
          autoIncrement: true, 
          primaryKey: true
        },
    access_token: DataTypes.STRING,
    refresh_token: DataTypes.STRING,
    environment_hash: DataTypes.STRING 
  }, {
    tableName: 'mercadolibres',
    underscored: true,
    timestamps: true
  }

  );

  MercadoLibre.belongsTo(User);

  return MercadoLibre;
}; …
Run Code Online (Sandbox Code Playgroud)

javascript node.js sequelize.js

3
推荐指数
1
解决办法
5687
查看次数

pip install boto3出错

我正试着跑:

pip install boto3
Run Code Online (Sandbox Code Playgroud)

但是我收到了这个错误:

DEPRECATION: Uninstalling a distutils installed project (six) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
OSError: [Errno 1] Operation not permitted: '/tmp/pip-ueLGpf-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info'
Run Code Online (Sandbox Code Playgroud)

python boto python-2.7 boto3

3
推荐指数
1
解决办法
2586
查看次数

AttributeError:dlsym(0x7fe512579830,EVP_CIPHER_CTX_reset):找不到符号

我正在尝试使用此包pywebpush,但我收到此错误:

AttributeError: dlsym(0x7fe512579830, EVP_CIPHER_CTX_reset): symbol not found
Run Code Online (Sandbox Code Playgroud)

这是整个追溯:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/pywebpush/__init__.py", line 15, in <module>
    import http_ece
  File "/usr/local/lib/python2.7/site-packages/http_ece/__init__.py", line 12, in <module>
    from pyelliptic import ecc
  File "/usr/local/lib/python2.7/site-packages/pyelliptic/__init__.py", line 43, in <module>
    from .openssl import OpenSSL
  File "/usr/local/lib/python2.7/site-packages/pyelliptic/openssl.py", line 310, in <module>
    OpenSSL = _OpenSSL(libname)
  File "/usr/local/lib/python2.7/site-packages/pyelliptic/openssl.py", line 144, in __init__
    self.EVP_CIPHER_CTX_reset = self._lib.EVP_CIPHER_CTX_reset
  File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 375, in __getattr__
    func = self.__getitem__(name)
  File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 380, …
Run Code Online (Sandbox Code Playgroud)

python macos python-2.7

3
推荐指数
1
解决办法
1298
查看次数

Python 解析 XML 提要错误:XPathEvalError:未定义的命名空间前缀

我正在尝试处理 XML 文件,但出现此错误:

XPathEvalError: Undefined namespace prefix
Run Code Online (Sandbox Code Playgroud)

在这一行:

print "category =", item.xpath("./g:google_product_category")
Run Code Online (Sandbox Code Playgroud)

这是 XML 文件:

<rss xmlns:g="http://base.google.com/ns/1.0" version="2.0">
<channel>
<title>example.net.br</title>
<link>http://www.example.net.br/</link>
<description>Data feed description.</description>
<item>
<title>
<![CDATA[
example
]]>
</title>
<link>
<![CDATA[
example
]]>
</link>
<description>
<![CDATA[
example]]>
</description>
<g:google_product_category>
<![CDATA[
example
]]>
</g:google_product_category>
...
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

headers = { 'User-Agent' : 'Mozilla/5.0' }
req = urllib2.Request(feed_url, None, headers)
file = urllib2.urlopen(req).read()

file = etree.fromstring(file)
for item in file.xpath('/rss/channel/item'):
    print "title =", item.xpath("./title/text()")[0]
    print "link =", item.xpath("./link/text()")[0]
    print "description =", item.xpath("./description/text()")[0] …
Run Code Online (Sandbox Code Playgroud)

python xml lxml

3
推荐指数
1
解决办法
2137
查看次数

pip上的错误代码1安装MySQL-python

我在osX上尝试这个:

pip install MySQL-python
Run Code Online (Sandbox Code Playgroud)

但是我收到了这个错误:

Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-build-istycM/MySQL-python/
Run Code Online (Sandbox Code Playgroud)

这是完整的信息:

Collecting MySQL-python
  Downloading MySQL-python-1.2.5.zip (108kB)
    100% |????????????????????????????????| 112kB 189kB/s 
    Complete output from command python setup.py egg_info:
    sh: mysql_config: command not found
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/tmp/pip-build-istycM/MySQL-python/setup.py", line 17, in <module>
        metadata, options = get_config()
      File "setup_posix.py", line 43, in get_config
        libs = mysql_config("libs_r")
      File "setup_posix.py", line 25, in mysql_config
        raise EnvironmentError("%s not found" % (mysql_config.path,)) …
Run Code Online (Sandbox Code Playgroud)

python mysql pip setuptools mysql-python

3
推荐指数
1
解决办法
4275
查看次数

从Google财经获取Google表格上的BTC价格

我正试图通过以下公式从Google表格中获取Google财经数据:

=GoogleFinance("CURRENCY:BTC")
Run Code Online (Sandbox Code Playgroud)

但是我收到了这个错误:

GOOGLEFINANCE, the query for the symbol: 'CURRENCY:BTC' returned no data.
Run Code Online (Sandbox Code Playgroud)

虽然在Google财经上,我可以获得BTC价格:

https://www.google.com/finance?q=CURRENCY:BTC
Run Code Online (Sandbox Code Playgroud)

使用相同的查询字符串.

我怎么能解决这个问题?

google-finance google-sheets bitcoin

3
推荐指数
2
解决办法
5353
查看次数