当前位置: 首页 > 面试题库 >

用pip安装Python模块

白泽语
2023-03-14
问题内容

我正在尝试安装一个名为Scrapy的模块。我使用安装

pip install Scrapy

我在/usr/local/lib/python2.7/site-packages中看到’scrapy’文件夹,但是当我尝试将其导入Python程序时,据说没有该名称的模块。关于为什么会发生这种情况的任何想法?

编辑:这是pip命令的输出:

    Downloading/unpacking Scrapy
  Downloading Scrapy-0.20.0.tar.gz (745kB): 745kB downloaded
  Running setup.py egg_info for package Scrapy

    no previously-included directories found matching 'docs/build'
Requirement already satisfied (use --upgrade to upgrade): Twisted>=10.0.0 in /usr/local/lib/python2.7/site-packages (from Scrapy)
Requirement already satisfied (use --upgrade to upgrade): w3lib>=1.2 in /usr/local/lib/python2.7/site-packages (from Scrapy)
Requirement already satisfied (use --upgrade to upgrade): queuelib in /usr/local/lib/python2.7/site-packages (from Scrapy)
Requirement already satisfied (use --upgrade to upgrade): lxml in /usr/local/lib/python2.7/site-packages (from Scrapy)
Requirement already satisfied (use --upgrade to upgrade): pyOpenSSL in /usr/local/lib/python2.7/site-packages (from Scrapy)
Requirement already satisfied (use --upgrade to upgrade): cssselect>=0.9 in /usr/local/lib/python2.7/site-packages (from Scrapy)
Requirement already satisfied (use --upgrade to upgrade): zope.interface>=3.6.0 in /usr/local/lib/python2.7/site-packages (from Twisted>=10.0.0->Scrapy)
Requirement already satisfied (use --upgrade to upgrade): six>=1.4.1 in /usr/local/lib/python2.7/site-packages (from w3lib>=1.2->Scrapy)
Requirement already satisfied (use --upgrade to upgrade): setuptools in /usr/local/lib/python2.7/site-packages/setuptools-1.1.6-py2.7.egg (from zope.interface>=3.6.0->Twisted>=10.0.0->Scrapy)
Installing collected packages: Scrapy
  Running setup.py install for Scrapy
    changing mode of build/scripts-2.7/scrapy from 644 to 755

    no previously-included directories found matching 'docs/build'
    changing mode of /usr/local/bin/scrapy to 755
Successfully installed Scrapy
Cleaning up...

当我运行/ usr / local / bin / scrapy时,会得到命令和可用命令的用法。我注意到我在/ usr / local / bin中有一个python2.7和python2.7-32,并且我记得由于Mavericks的问题而安装了32位版本。

这是输出python /usr/local/bin/scrapy:

Traceback (most recent call last): File "/usr/local/bin/scrapy", line 3, in <module> from scrapy.cmdline import execute ImportError: No module named scrapy.cmdline 

head /usr/local/bin/scrapy:

#!/usr/local/opt/python/bin/python2.7 from scrapy.cmdline import execute execute()

问题答案:

你是否正在使用Homebrew或MacPorts或其他产品?正如@JFSebastian所说,听起来你在混合OS X附带的默认python和通过软件包管理器安装的默认python时遇到了问题…请尝试/usr/local/opt/python/bin/python2.7 -m scrapy看看是否抛出ImportError

如果这样的作品,那么你可能要考虑让该 Python可执行程序的默认。诸如此类的东西alias python2.7=/usr/local/opt/python/bin/python2.7,然后总是使用python2.7而不是默认值python。同样,你也可以指向python该/urs/local...位,但是如果你出于某种原因需要它,将无法轻松访问系统(由OS X提供)的python。



 类似资料:
  • 我正在尝试安装一个名为Scrapy的模块。我是用电脑安装的 我在my/usr/local/lib/python2中看到了“scrapy”文件夹。7/site包,但当我尝试在Python程序中导入它时,它说没有这个名称的模块。你知道为什么会这样吗? 编辑:以下是pip命令的输出: 当我运行 /usr/local/bin/scrapy我得到命令和可用命令的用法。我注意到我的 /usr/local/bi

  • 问题内容: 如何使用pip为Python 安装MySQLdb模块? 问题答案: 这很容易,但是很难记住正确的拼写: 如果您需要1.2.x版本(仅限旧版Python),请使用 注意:运行上述命令时,某些依赖项可能必须存在。关于如何在各种平台上安装这些的一些提示: Ubuntu 14,Ubuntu 16,Debian 8.6(jessie) Fedora 24: 苹果系统 如果失败,请尝试

  • 我知道在这方面也有类似的问题。例如,这一条:为Python安装pip、virtualenv和distribute的正确方法是什么? 我想安装这些模块按照我的学习Python的硬的方式教程:http://learnpythonthehardway.org/book/ex46.html 我设法(我想)通过使用sudoeasy_installpip安装pip,但是当我运行pydoc模块时,我看不到它。所

  • 我尝试使用pip安装rpy2。 用户I windows 10. 我使用admin选项在cmd控制台中运行pip命令 但是,我收到此错误: 安装rpy2 -c'导入系统、设置工具、标记化;系统。argv[0]=“C:\Users\Mary\AppData\Local\Temp\pip-install-bov9dean\rpy2\setup。py''';文件='“'”C:\Users\Mary\App

  • 我以前在其他文章中看到过这个问题,建议在安装python包时使用可信主机前缀。这一直对我有效,但现在,无论出于什么原因,不再有效。这是我通过Pypi安装任何Python包时得到的消息。组织。不管涉及什么包,我都会得到同样的错误。 我试图改变condarc文件,将ssl_verify为false,这似乎没有帮助,我得到了同样的消息。有什么想法吗? 我正在通过Anaconda运行最新版本的Python

  • 我刚刚在我的MAC(约塞米蒂)上安装了Python3.4.3。我需要安装几个lxml,但是每次输入:pip install/“”/时,我都会得到错误消息。我已经遵循了多个教程,并且安装了pip。MAC已经有Python2.7.,但我安装了3.4.3。版本,不确定这是否是问题所在。错误消息为: brunos-macbook-pro:~brunopaesleme$pip install/macinto