简体   繁体   English

使用Virtualenv在Ubuntu上安装Pip NLTK安装问题

[英]Pip NLTK install issue on Ubuntu using Virtualenv

For reference here is the nltk installation documentation nltk here 这里有nltk安装文档nltk供参考

Is there a way to install nltk using pip and virtualenv? 有没有办法使用pip和virtualenv安装nltk? I have installed the dependencies using pip into my virtualenv but when I attempt to install nltk it fails. 我已经使用pip将依赖项安装到我的virtualenv中但是当我尝试安装nltk时它失败了。

The error is that there is no setup script. 错误是没有安装脚本。 There is source installation instructions for linux on the nltk site to do sudo python setup.py install. 在nltk网站上有linux的源安装说明来做sudo python setup.py安装。 But how could I do this into a virtualenv? 但是我怎么能把它变成一个virtualenv呢?

Pip downloads and starts to install nltk so surely they plan for people to use pip if its in the package index. Pip下载并开始安装nltk,所以他们肯定会计划人们在包索引中使用pip。

It looks like pip is grabbing the first .tar.gz package from PyPI. 看起来pip正在从PyPI中获取第一个.tar.gz包。 For nltk, this is a macosx binary. 对于nltk,这是一个macosx二进制文件。 You will have to explicitly point pip to the correct package. 您必须明确指向正确的包。

The easiest way to do this is to just provide the full path to the package. 最简单的方法是提供包的完整路径。

pip install http://pypi.python.org/packages/source/n/nltk/nltk-2.0.1rc1.tar.gz

The other solution is to download the package to a known directory and install it from there. 另一种解决方案是将软件包下载到已知目录并从那里安装。 For example, say you download the package to ~/Downloads . 例如,假设您将软件包下载到~/Downloads The command would be: 命令是:

pip install ~/Downloads/nltk-2.0.1rc1.tar.gz

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM