Scrapy似乎已安装,但检查版本时提示“No module named scrapy”

2 投票
2 回答
3478 浏览
提问于 2025-04-18 16:36

我已经安装了需要的依赖项(比如openssl、lxml、pyopenssl、twisted matrix等等),当我输入这个命令时

easy_install Scrapy

看起来是正常工作的,并且给了我这个输出

Searching for scrapy
Best match: scrapy 0.24.2
Processing scrapy-0.24.2-py2.7.egg
scrapy 0.24.2 is already the active version in easy-install.pth
Installing scrapy script to C:\Users\Joel\AppData\Local\Enthought\Canopy\User\Sc
ripts
Installing scrapy.bat script to C:\Users\Joel\AppData\Local\Enthought\Canopy\Use
r\Scripts

Using c:\users\joel\appdata\local\enthought\canopy\user\lib\site-packages\scrapy
-0.24.2-py2.7.egg
Processing dependencies for scrapy
Finished processing dependencies for scrapy

但是,当我检查scrapy的版本时,却出现了这个错误

C:\python27\python.exe: No module named scrapy

我该怎么安装scrapy呢?我想要抓取网页...

补充说明:当我使用

pip install scrapy

时,我收到了这个错误 ************************************************************************


WARNING:

        An optional code optimization (C extension) could not be compiled.

        Optimizations for this package will not be available!
()
Could not find Visual Studio 2008 in your path.

If you do not have Visual Studio 2008 installed, you can use
the MinGW compiler instead. To install mingw, do:
    enpkg mingw
To use the MinGW compiler to build an extension module, use
the '-c' flag, e.g.:
    python setup.py build_ext -c mingw64
Note that building Python extensions with MinGW is not officially
supported, although it is known to work in many cases.
****************************************************************************

我安装了visual studio 2008,所以可能我的路径没有指向那里?如果是这样,我需要添加什么环境变量才能让它识别到呢?

2 个回答

0

你确定你已经安装了所有需要的依赖吗?

  • 环境变量
  • OpenSSL
  • Visual C++

请查看这个链接,告诉我们你是怎么检查版本的,以及遇到了什么错误。http://doc.scrapy.org/en/latest/intro/install.html#intro-install-platform-notes

看起来你正在安装正确版本的Python,但你可以尝试一下

easy_install-2.7 scrapy
0

看起来这是有可能的,因为你似乎加载了Enthought的版本,可能你运行的easy_install用的是和你输入“python”命令时不同的Python版本(也就是说,一个是Enthought的版本,一个是你系统自带的Python,除了Alex Gaynor,大家都应该尽量不去动这个)。你可以通过输入which easy_installwhich python命令来检查一下。

如果它们确实指向同一个Python程序,那我就有点困惑了。

撰写回答