创建Scrapy项目报错 UnicodeDecodeError: 'ascii' codec can't decode byte 0xa3 in position 19

刚安装好,创建Scrapy 项目报错:


D:\py_workspace\test_scrapy>scrapy startobject a
Traceback (most recent call last):
  File "d:\python27\lib\runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "d:\python27\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "D:\Python27\Scripts\scrapy.exe\__main__.py", line 5, in <module>
  File "d:\python27\lib\site-packages\scrapy\cmdline.py", line 9, in <module>
    from scrapy.crawler import CrawlerProcess
  File "d:\python27\lib\site-packages\scrapy\crawler.py", line 7, in <module>
    from twisted.internet import reactor, defer
  File "d:\python27\lib\site-packages\twisted\internet\reactor.py", line 38, in
<module>
    from twisted.internet import default
  File "d:\python27\lib\site-packages\twisted\internet\default.py", line 56, in
<module>
    install = _getInstallFunction(platform)
  File "d:\python27\lib\site-packages\twisted\internet\default.py", line 50, in
_getInstallFunction
    from twisted.internet.selectreactor import install
  File "d:\python27\lib\site-packages\twisted\internet\selectreactor.py", line 1
8, in <module>
    from twisted.internet import posixbase
  File "d:\python27\lib\site-packages\twisted\internet\posixbase.py", line 18, i
n <module>
    from twisted.internet import error, udp, tcp
  File "d:\python27\lib\site-packages\twisted\internet\tcp.py", line 28, in <mod
ule>
    from twisted.internet._newtls import (
  File "d:\python27\lib\site-packages\twisted\internet\_newtls.py", line 21, in
<module>
    from twisted.protocols.tls import TLSMemoryBIOFactory, TLSMemoryBIOProtocol
  File "d:\python27\lib\site-packages\twisted\protocols\tls.py", line 41, in <mo
dule>
    from OpenSSL.SSL import Error, ZeroReturnError, WantReadError
  File "d:\python27\lib\site-packages\OpenSSL\__init__.py", line 8, in <module>
    from OpenSSL import rand, crypto, SSL
  File "d:\python27\lib\site-packages\OpenSSL\crypto.py", line 12, in <module>
    from cryptography import x509
  File "d:\python27\lib\site-packages\cryptography\x509\__init__.py", line 9, in
 <module>
    from cryptography.x509.base import (
  File "d:\python27\lib\site-packages\cryptography\x509\base.py", line 16, in <m
odule>
    from cryptography.x509.extensions import Extension, ExtensionType
  File "d:\python27\lib\site-packages\cryptography\x509\extensions.py", line 13,
 in <module>
    from asn1crypto.keys import PublicKeyInfo
  File "d:\python27\lib\site-packages\asn1crypto\keys.py", line 22, in <module>
    from ._elliptic_curve import (
  File "d:\python27\lib\site-packages\asn1crypto\_elliptic_curve.py", line 51, i
n <module>
    from ._int import inverse_mod
  File "d:\python27\lib\site-packages\asn1crypto\_int.py", line 56, in <module>
    from ._perf._big_num_ctypes import libcrypto
  File "d:\python27\lib\site-packages\asn1crypto\_perf\_big_num_ctypes.py", line
 31, in <module>
    libcrypto_path = find_library('crypto')
  File "d:\python27\lib\ctypes\util.py", line 51, in find_library
    fname = os.path.join(directory, name)
  File "d:\python27\lib\ntpath.py", line 85, in join
    result_path = result_path + p_path
UnicodeDecodeError: 'ascii' codec can't decode byte 0xa3 in position 19: ordinal
 not in range(128)


解决方法:

D:\Python27\Lib 下  ntpath.py

在import库后面添加:

reload(sys)  
sys.setdefaultencoding('gbk')


再次运行就ok了。





                
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值