23

I have downloaded a zip file from here but 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

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

creating build\temp.win-amd64-2.7\Release\libwapiti\src
C:\Users\Mohammad\AppData\Local\Programs\Common\Microsoft\Visual C++ for Pyt
hon\9.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\9.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:

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
  • also I get an error using "pip install hazm" – mohammad eslahi sani May 10 '15 at 06:19
  • 1
    "I get an error" doesn't help anyone solve your problem. Show us what you tried and what happened. (Because `pip install hazm` is the right answer, as [the project's readme](https://github.com/sobhe/hazm/) explicitly says.) – abarnert May 10 '15 at 06:23
  • @abarnert i added the errors i get using that command – mohammad eslahi sani May 10 '15 at 06:47
  • Your question title attracts views, but you selected an answer that solved your specific problem without answering the question in the title. Please consider marking the popular, direct answer as the solution. – Hack-R Jul 08 '18 at 17:09

6 Answers6

56

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:

pip install hazm-master.zip

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

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

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

pip install hazm
abarnert
  • 354,177
  • 51
  • 601
  • 671
  • 8
    On a machine with no internet access, installing from a zip can be necessary! Download zip to other machine, transfer it to blocked machine, and install. – Samuel Lelièvre May 29 '19 at 07:35
  • 1
    You can even use to directly download and install a zip online. I wanted to install the big-O module from github and all I had to do was `pip install https://github.com/pberkes/big_O/archive/v0.9.zip` – Giacomo Pigani Nov 07 '19 at 09:18
  • 1
    On a machine with no admin rights, you will also need to `pip install --user fname.zip` . Find the resulting site-packages under AppData\Roaming when you are using MS – rleir Jan 29 '20 at 14:30
3

As far as I know, hazm 0.5 uses libwapiti for its POS Tagger class and I'd the exact same related problem installing hazm over 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:

sudo pip install hazm

or

sudo pip3 install hazm

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

pip install hazm==0.4
Vynylyn
  • 172
  • 11
2

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

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

Your problem appears to be with libwapiti, which requires a C compiler, and presumably also the Wapiti C library. I'm not actually sure that Wapiti and libwapiti actually 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.

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

  • Download, make, and install Wapiti (see the link above, and read the instructions on their website or inside the package).
  • pip install hazm again.
abarnert
  • 354,177
  • 51
  • 601
  • 671
1

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.

0

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

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.py file, you can do this using the following command (assuming you are in the hazm-master folder):

python ./setup.py
python2 ./setup.py #Explicit python 2 selection
python3 ./setup.py #Explicit python 3 selection
Leo2807
  • 64
  • 3
  • 1
    You don't have to run `setup.py` to use that file. `pip` has been able to install from directories since way back in the 0.x days, and it's been able to install from zip archives since… I think 1.5. – abarnert May 10 '15 at 06:53
  • 1
    This answer doesn't match the question title, so it may have been good for OP but is bad for future readers – Hack-R Jul 08 '18 at 17:08
0

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 wapiti and libwapiti. I suggest installing and using hazm 0.4 or 0.3. Not every update makes life easier, believe me!

Vynylyn
  • 172
  • 11