python - 如何安装来自 Github (Mac) 的 python 应用程序 portia

标签 python git github web-scraping scrapy

我正在尝试安装来自 Github 的 Python 应用程序 Portia:https://github.com/scrapinghub/portia

我在命令行中使用以下步骤:

  1. 在 Mac 终端中设置新的 virtualenv 'portia'
  2. git 克隆 https://github.com/scrapinghub/portia.git
  3. 遵循自述说明:

    cd slyd

    pip install -r requirements.txt

  4. 运行 Portia

    cd slyd

    twistd -n slyd

但每次我尝试执行程序的最后一步时,都会出现以下错误:

ImportError: 没有名为 scrapy 的模块

知道为什么会出现这个错误吗?前面的所有步骤似乎都安装正确。这是我安装过程中的错误吗?

谢谢!

最佳答案

我没有代表支持 Alagappan 的回答,但他是正确的。另外,如果您像我一样缺乏经验,您可能需要进一步了解这一点。

在安装任何东西(包括从 github 克隆 portia)之前,您必须创建、激活并导航到 virtualenv。这是从开始到结束的整个过程:

1: cd 到您想要存储项目的任何位置... 和 安装virtualenv:

$ pip install virtualenv

2:创建虚拟环境。 (我称我的为“portia”,但这可以是任何名称。):

$ virtualenv portia

3:激活您创建的虚拟环境 (更改路径以反射(reflect)您在此处使用的名称,如果不是“portia”。):

$ source portia/bin/activate

此时您的终端应该在标准目录路径提示之前的括号中显示 virtualenv 名称: (name-of-virtualenv) [your-machine]:[current-directory ]: [用户]$ ...如果您在密码中列出文件,您会在那里看到您的 virtualenv 的名称。

4: cd 进入你的虚拟环境(对我来说是“portia”):

$ cd portia

5:现在你可以从 github 克隆 portia 到你的 virtualenv 中......

$ git clone https://github.com/scrapinghub/portia

6: cd 进入克隆的 portia/slyd...

$ cd portia/slyd

7/8:pip install twisted 和 Scrapy...

$ pip install twisted
$ pip install Scrapy

你的 virtualenv 应该仍然被激活并且你应该仍然在 [virtualenv-name]/portia/slyd

9:安装requirements.txt:

$ pip install -r requirements.txt

10:运行 slyd:

$ twistd -n slyd

--- 不再有 scrapy 错误! ---

关于python - 如何安装来自 Github (Mac) 的 python 应用程序 portia,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23453054/

相关文章:

python - 当我的文件相互导入时,导入不起作用

python - C++:迭代时std::vector中的push_back

python - 在 Python/Django 中显示 friend 关注的 Twitter 关注者

java - 项目迁移到新目录 - 保留 Git 历史记录

在 dict 中移动所有键的 Pythonic 方法

git - 如何将 Git 配置为在分支更改时自动从原点 pull ?

git - "Merge remote-tracking branch ' xxx/master'"是否为 Pull Request 带来了麻烦?

Android studio 如何从github源构建项目

git - GitHub pull 请求上的 HTTP 403

aptana studio 的 Git 插件