创建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 
  File "d:\python27\lib\site-packages\scrapy\cmdline.py", line 9, in 
    from scrapy.crawler import CrawlerProcess
  File "d:\python27\lib\site-packages\scrapy\crawler.py", line 7, in 
    from twisted.internet import reactor, defer
  File "d:\python27\lib\site-packages\twisted\internet\reactor.py", line 38, in

    from twisted.internet import default
  File "d:\python27\lib\site-packages\twisted\internet\default.py", line 56, in

    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 
    from twisted.internet import posixbase
  File "d:\python27\lib\site-packages\twisted\internet\posixbase.py", line 18, i
n 
    from twisted.internet import error, udp, tcp
  File "d:\python27\lib\site-packages\twisted\internet\tcp.py", line 28, in 
    from twisted.internet._newtls import (
  File "d:\python27\lib\site-packages\twisted\internet\_newtls.py", line 21, in

    from twisted.protocols.tls import TLSMemoryBIOFactory, TLSMemoryBIOProtocol
  File "d:\python27\lib\site-packages\twisted\protocols\tls.py", line 41, in 
    from OpenSSL.SSL import Error, ZeroReturnError, WantReadError
  File "d:\python27\lib\site-packages\OpenSSL\__init__.py", line 8, in 
    from OpenSSL import rand, crypto, SSL
  File "d:\python27\lib\site-packages\OpenSSL\crypto.py", line 12, in 
    from cryptography import x509
  File "d:\python27\lib\site-packages\cryptography\x509\__init__.py", line 9, in
 
    from cryptography.x509.base import (
  File "d:\python27\lib\site-packages\cryptography\x509\base.py", line 16, in 
    from cryptography.x509.extensions import Extension, ExtensionType
  File "d:\python27\lib\site-packages\cryptography\x509\extensions.py", line 13,
 in 
    from asn1crypto.keys import PublicKeyInfo
  File "d:\python27\lib\site-packages\asn1crypto\keys.py", line 22, in 
    from ._elliptic_curve import (
  File "d:\python27\lib\site-packages\asn1crypto\_elliptic_curve.py", line 51, i
n 
    from ._int import inverse_mod
  File "d:\python27\lib\site-packages\asn1crypto\_int.py", line 56, in 
    from ._perf._big_num_ctypes import libcrypto
  File "d:\python27\lib\site-packages\asn1crypto\_perf\_big_num_ctypes.py", line
 31, in 
    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了。




 
 

你可能感兴趣的:(创建Scrapy项目报错 UnicodeDecodeError: 'ascii' codec can't decode byte 0xa3 in position 19)