使用 zip 文件安装 python 模块

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30148335/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 08:01:04  来源:igfitidea点击:

install python module using a zip file

pythonmodulepip

提问by mohammad eslahi sani

I have downloaded a zip file from herebut I don't know how to install it and then use it in my python 2.7 they said it supports both python 2 and 3

我已经从这里下载了一个 zip 文件,但我不知道如何安装它,然后在我的 python 2.7 中使用它,他们说它支持 python 2 和 3

using command: "pip install hazm" after bunch of lines it gets to these errors:

使用命令:“pip install hazm”在一堆行之后会出现这些错误:

creating build\temp.win-amd64-2.7\Release\libwapiti\src
C:\Users\Mohammad\AppData\Local\Programs\Common\Microsoft\Visual C++ for Pyt
hon.0\VC\Bin\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Icwapiti/src -
Ilibwapiti -IC:\Python27\include -IC:\Python27\PC /Tccwapiti/src/bcd.c /Fobuild\
temp.win-amd64-2.7\Release\cwapiti/src/bcd.obj -std=c99
cl : Command line warning D9002 : ignoring unknown option '-std=c99'
bcd.c
cwapiti/src/bcd.c(30) : fatal error C1083: Cannot open include file: 'stdboo
l.h': No such file or directory
error: command '"C:\Users\Mohammad\AppData\Local\Programs\Common\Microsoft\V
isual C++ for Python.0\VC\Bin\amd64\cl.exe"' failed with exit status 2

----------------------------------------
Command "C:\Python27\python.exe -c "import setuptools, tokenize;__file__='c:
\users\mohammad\appdata\local\temp\pip-build-y3whx6\libwapiti\setup.py';
exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\
n'), __file__, 'exec'))" install --record c:\users\mohammad\appdata\local\temp\p
ip-m_wrwt-record\install-record.txt --single-version-externally-managed --compil
e" failed with error code 1 in c:\users\mohammad\appdata\local\temp\pip-build-y3
whx6\libwapiti

and when I use command:"python ./setup.py" these errors show up:

当我使用 command:"python ./setup.py" 这些错误出现:

C:\Users\Mohammad\Desktop\Term 6\AI\AI Project\OPERATE\hazm-master\hazm-master>p
ython ./setup.py
C:\Python27\lib\distutils\dist.py:267: UserWarning: Unknown distribution option:
'install_requires'
 warnings.warn(msg)
 usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
 or: setup.py --help [cmd1 cmd2 ...]
 or: setup.py --help-commands
 or: setup.py cmd --help

 error: no commands supplied

采纳答案by Leo2807

This package is on PyPI, so all you have to do is run the following command:

这个包在 PyPI 上,所以你所要做的就是运行以下命令:

pip install hazm
pip2 install hazm #Explicit python 2 selection
pip3 install hazm #Explicit python 3 selection

If you really want to use that file, you have to run the setup.pyfile, you can do this using the following command (assuming you are in the hazm-master folder):

如果您真的想使用该文件,则必须运行该setup.py文件,您可以使用以下命令执行此操作(假设您位于 hazm-master 文件夹中):

python ./setup.py
python2 ./setup.py #Explicit python 2 selection
python3 ./setup.py #Explicit python 3 selection

回答by abarnert

The right way to install a zipfile (at least if it's properly designed, but I just tested this one, and it is) is with pip:

安装 zipfile 的正确方法(至少如果它设计得当,但我刚刚测试了这个,并且确实如此)是pip

pip install hazm-master.zip

Or, if you prefer, you can unzip it and use pipfrom within the directory:

或者,如果您愿意,可以解压缩它并pip在目录中使用:

unzip hazm-master.zip
cd hazm-master
pip install .

But neither of these is really necessary, because, as the project's readmesays, you don't need to download it manually; just do:

但这些都不是真正必要的,因为正如项目的自述文件所说,您不需要手动下载它;做就是了:

pip install hazm

回答by abarnert

In order to install hazm, you need to install all of its prerequisites.

为了安装hazm,您需要安装它的所有先决条件。

If you install it with pip install hazmor pip install hazm-master.zip, pipwill try to fetch and install all of them for you. If you unzip it and run setup.pymanually, you have to take care of figuring out and installing all the prerequisites on your own (and possibly telling hazmhow to find them); that isn't going to solve anything.

如果您使用pip install hazm或安装它pip install hazm-master.zippip将尝试为您获取并安装所有这些。如果您将其解压缩并setup.py手动运行,您必须自己弄清楚并安装所有先决条件(并可能告诉hazm如何找到它们);这不会解决任何问题。

Your problem appears to be with libwapiti, which requires a C compiler, and presumably also the WapitiC library. I'm not actually sure that Wapitiand libwapitiactually work natively on Windows at all. Maybe they do, but if not, all you can do is port them yourself, file a feature request on their issue trackers, or use Cygwin instead of native Windows.

您的问题似乎与libwapiti,它需要一个 C 编译器,并且大概也是WapitiC 库。我实际上并不确定,Wapiti并且libwapiti实际上根本无法在 Windows 上本地工作。也许他们会这样做,但如果没有,您所能做的就是自己移植它们,在他们的问题跟踪器上提交功能请求,或者使用 Cygwin 而不是本机 Windows。

At any rate, ifthey support Windows, what you need to do should be:

无论如何,如果他们支持 Windows,你需要做的应该是:

  • Download, make, and install Wapiti(see the link above, and read the instructions on their website or inside the package).
  • pip install hazmagain.
  • 下载、制作和安装Wapiti(请参阅上面的链接,并阅读其网站上或包装内的说明)。
  • pip install hazm再次。

回答by mohammad eslahi sani

I checked libwapiti and it seems to be working just on linux. because of that i couden't install hazm on windows. at last i could install hazm on linux.

我检查了 libwapiti,它似乎只在 linux 上工作。因此,我不会在 Windows 上安装危险品。最后我可以在 linux 上安装 hazm。

回答by Vynylyn

As far as I know, hazm 0.5uses libwapitifor its POS Taggerclass and I'd the exact same related problem installing hazmover Windows 7. For Python 2.7, you've got to use MS VC++ 2008 (a.k.a 9.00) for Python 2.7(available on Microsoft's site) for some packages including hazm. But the pain won't be finished here! MSVC9 does not have some C++ header files like stdbool.h and a few others which you've got to create or copy-paste manually in MSVC installition folder. If you want to use hazm 0.5, the best you can do is to install and use it on Linux:

据我所知,hazm 0.5使用libwapitiPOS标注器类,我会安装完全相同的相关问题,hazm在Windows 7中对于Python 2.7,你必须使用MS VC ++ 2008(又名9.00)为Python 2.7(适用于微软的站点)用于某些软件包,包括hazm. 但痛苦不会在这里结束!MSVC9 没有一些 C++ 头文件,如 stdbool.h 和其他一些你必须在 MSVC 安装文件夹中手动创建或复制粘贴的文件。如果你想使用 hazm 0.5,你能做的最好的事情就是在 Linux 上安装和使用它:

sudo pip install hazm

or

或者

sudo pip3 install hazm

But if you need to use it under Windows OS you can use hazm 0.4which does not need the troublesome libwapitimodule as recommanded by hazm's creator:

但是如果你需要在 Windows 操作系统下使用它,你可以使用hazm 0.4它不需要libwapitihazm 的创建者推荐的麻烦模块:

pip install hazm==0.4

回答by Vynylyn

Based on my experience - after several times that I'd to reinstall Windows/Ubuntu and so Python and its packages including hazm, I'd avoid going for its new version due some of its prerequisites which made me several problems before I figure them out. For Ubuntu it was okay but for Windows I couldn't collect and setup all prerequisites like wapitiand libwapiti. I suggest installing and using hazm 0.4 or 0.3. Not every update makes life easier, believe me!

根据我的经验 - 在我多次重新安装 Windows/Ubuntu 以及 Python 及其软件包(包括hazm. 对于 Ubuntu 来说没问题,但对于 Windows,我无法收集和设置所有先决条件,例如wapitilibwapiti。我建议安装和使用 hazm 0.4 或 0.3。并非每次更新都会让生活更轻松,相信我!