【python】TypeError: expected str, bytes

系统 2356 0

python版本:3.7

scrapy版本:1.7.1

 

问题描述

在这个目录下正常生成

(venv) G:\Users\Administrator\PycharmProjects\pythonPratice\code\spider\day04>scrapy genspider tttt itcast.cn
Created spider 'tttt' using template 'basic'
 

在下一级及以下目录生成失败,mySpider及以下为通过scrapy startproject生成

(venv) G:\Users\Administrator\PycharmProjects\pythonPratice\code\spider\day04\mySpider>scrapy genspider tttt itcast.cn

            
              (venv) G:\Users\Administrator\PycharmProjects\pythonPratice\code\spider\day04\mySpider>scrapy genspider tttt itcast.cn
Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "G:\Users\Administrator\PycharmProjects\pythonPratice\venv\Scripts\scrapy.exe\__main__.py", line 9, in 
              
                
  File "g:\users\administrator\pycharmprojects\pythonpratice\venv\lib\site-packages\scrapy\cmdline.py", line 146, in execute
    _run_print_help(parser, _run_command, cmd, args, opts)
  File "g:\users\administrator\pycharmprojects\pythonpratice\venv\lib\site-packages\scrapy\cmdline.py", line 100, in _run_print_help
    func(*a, **kw)
  File "g:\users\administrator\pycharmprojects\pythonpratice\venv\lib\site-packages\scrapy\cmdline.py", line 154, in _run_command
    cmd.run(args, opts)
  File "g:\users\administrator\pycharmprojects\pythonpratice\venv\lib\site-packages\scrapy\commands\genspider.py", line 82, in run
    self._genspider(module, name, domain, opts.template, template_file)
  File "g:\users\administrator\pycharmprojects\pythonpratice\venv\lib\site-packages\scrapy\commands\genspider.py", line 99, in _genspi
der
    spiders_dir = abspath(dirname(spiders_module.__file__))
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\ntpath.py", line 221, in dirname
    return split(p)[0]
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\ntpath.py", line 183, in split
    p = os.fspath(p)
TypeError: expected str, bytes or os.PathLike object, not NoneType

              
            
          

错误信息

TypeError: expected str, bytes or os.PathLike object, not NoneType

 

解决:

将工程全部删除然后重建

#创建工程

scrapy startproject itcast

#进入下一级目录

cd itcast

#创建爬虫

scrapy genspider myspider itcast.com

 

总结

感觉很气,费了将近2个小时最后也不晓得具体的问题原因是什么,但是删了重建又是对的


更多文章、技术交流、商务合作、联系博主

微信扫码或搜索:z360901061

微信扫一扫加我为好友

QQ号联系: 360901061

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描下面二维码支持博主2元、5元、10元、20元等您想捐的金额吧,狠狠点击下面给点支持吧,站长非常感激您!手机微信长按不能支付解决办法:请将微信支付二维码保存到相册,切换到微信,然后点击微信右上角扫一扫功能,选择支付二维码完成支付。

【本文对您有帮助就好】

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描上面二维码支持博主2元、5元、10元、自定义金额等您想捐的金额吧,站长会非常 感谢您的哦!!!

发表我的评论
最新评论 总共0条评论