scrapyd: error when deploying !!!

when I was deploying my project, there was a error that I coudn’t resovle! error message: {“status”: “error”, “message”: “environment can only contain strings”, “node_name”: “XSOOY-PC”}

server message:

 Traceback (most recent call last):
          File "c:\program files (x86)\python27\lib\site-packages\twisted\web\http.py", line 1694, in allContentReceived
            req.requestReceived(command, path, version)
          File "c:\program files (x86)\python27\lib\site-packages\twisted\web\http.py", line 790, in requestReceived
            self.process()
          File "c:\program files (x86)\python27\lib\site-packages\twisted\web\server.py", line 189, in process
            self.render(resrc)
          File "c:\program files (x86)\python27\lib\site-packages\twisted\web\server.py", line 238, in render
            body = resrc.render(self)
        --- <exception caught here> ---
          File "c:\program files (x86)\python27\lib\site-packages\scrapyd\webservice.py", line 21, in render
            return JsonResource.render(self, txrequest).encode('utf-8')
          File "c:\program files (x86)\python27\lib\site-packages\scrapyd\utils.py", line 20, in render
            r = resource.Resource.render(self, txrequest)
          File "c:\program files (x86)\python27\lib\site-packages\twisted\web\resource.py", line 250, in render
            return m(request)
          File "c:\program files (x86)\python27\lib\site-packages\scrapyd\webservice.py", line 86, in render_POST
            spiders = get_spider_list(project, version=version)
          File "c:\program files (x86)\python27\lib\site-packages\scrapyd\utils.py", line 132, in get_spider_list
            proc = Popen(pargs, stdout=PIPE, stderr=PIPE, env=env)
          File "c:\program files (x86)\python27\lib\subprocess.py", line 390, in __init__
            errread, errwrite)
          File "c:\program files (x86)\python27\lib\subprocess.py", line 640, in _execute_child
            startupinfo)
        exceptions.TypeError: environment can only contain strings

what should I do?

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 27 (9 by maintainers)

Most upvoted comments

Use Python 3 or install the latest Scrapyd from git instead.

@redapple ,yes it is relate to https://github.com/scrapy/scrapyd-client/issues/49 I found this problem lies in the method get_spider_list() in utils.py of scrapyd we must make sure that the value of the env passed into the Popen is str But in fact env[‘SCRAPY_PROJECT’] and env[‘SCRAPY_EGG_VERSION’] these two parameters from the outside is the Unicode type, if in python3 it will fine, but in the python2 we must first convert unicode to str , similar to Env[‘SCRAPY_PROJECT’] = str (project) Env[‘SCRAPY_EGG_VERSION’] = str (version) then is ok

@zhengxiansen, in scrapyd1.2, please replace print env with print [[n, type(n), v, type(v)] for n, v in env.items()] and copy/paste here the text output from your console (or your logfile). Please don’t use screenshots, they are very impractical. Just copy/paste the text here.