如何通过python3创建scrapy项目

编程入门 行业动态 更新时间:2024-10-27 10:22:22
本文介绍了如何通过python3创建scrapy项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我使用 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项目

本文发布于:2023-06-08 14:30:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/583103.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:项目   scrapy

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!