我使用 Mac OS,它有 python 2.7 和 python 3.4.我使用 pip install 命令在 python 2.7 中安装 scrapy.购买我也在python3.4中使用pip3 install命令安装scrapy...
I use Mac OS, it has python 2.7 and python 3.4. I use the pip install command to to install scrapy in python 2.7. Buy I also use the pip3 install command to install scrapy in python3.4 too...
我看了scrapy上的官方文档,我知道scrapy只支持python 2.7.当我使用命令 scrapy startproject tutorial 时,它会返回下面的错误.
I read the official documents on scrapy, I know that the scrapy just support the python 2.7. When I use the command scrapy startproject tutorial, it will return the errow below.
如何在 python 2.7 中使用命令 scrapy startproject tutorial?
How can I use the command scrapy startproject tutorial with python 2.7?
File "/Library/Frameworks/Python.framework/Versions/3.4/bin/scrapy", line 9, in <module> load_entry_point('Scrapy==1.1.0dev1', 'console_scripts', 'scrapy')() File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/Scrapy-1.1.0dev1-py3.4.egg/scrapy/cmdline.py", line 122, in execute cmds = _get_commands_dict(settings, inproject) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/Scrapy-1.1.0dev1-py3.4.egg/scrapy/cmdline.py", line 46, in _get_commands_dict cmds = _get_commands_from_module('scrapymands', inproject) File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/Scrapy-1.1.0dev1-py3.4.egg/scrapy/cmdline.py", line 29, in _get_commands_from_module for cmd in _iter_command_classes(module): File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/Scrapy-1.1.0dev1-py3.4.egg/scrapy/cmdline.py", line 21, in _iter_command_classes for obj in vars(module).itervalues(): AttributeError: 'dict' object has no attribute 'itervalues' 推荐答案使用 pip 安装 scrapy 会将一个可执行文件放在您的 PATH 中的某处.由于你安装了两次,python2 版本可能被覆盖了.要查找此文件,请使用命令 which scrapy.要查看文件的内容,请使用 cat $(which scrapy).它可能包含一行,内容如下:#!/usr/bin/python3.4 导致它使用不兼容的 python 版本.
Installing scrapy with pip will put an executable file somewhere in your PATH. Since you installed it two times, the python2 version was probably overwritten. To find this file use the command which scrapy. To see the content of the file use cat $(which scrapy). It probably contains a line the reads something like this: #!/usr/bin/python3.4 causing it to use an incompatible version of python.
要解决此问题,请卸载 python3 版本的 scrapy.
To fix this, uninstall the python3 version of scrapy.
pip3 uninstall scrapy然后使用 hash -r 或启动新的终端会话来清除 bash 中的命令缓存.
Then clean the command cache in bash by using hash -r or starting a new terminal session.
如果 scrapy 命令仍然不起作用,您可能还需要重新安装它的 python 2 版本.
If the scrapy command still doesn't work you might have to reinstall the python 2 version of it as well.
pip install scrapy --force-reinstall更多推荐
如何通过python3创建scrapy项目
发布评论