Offline installation missing
QtRoS opened this issue · 7 comments
In my organisation I have to deal with firewall, some URLs are simply blocked. In this case first usage of pymystem3 looks like:
Microsoft Windows [Version 6.1.7601]
C:\Users\qtros>ipython
Python 3.5.4 |Anaconda custom (64-bit)| (default, Aug 14 2017, 13:41:13) [MSC v.
1900 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 6.1.0 -- An enhanced Interactive Python. Type '?' for help.
`In [1]: from pymystem3 import Mystem`
In [2]: m = Mystem()
Installing mystem to C:\Users\qtros/.local/bin\mystem.exe from http://downloa
d.cdn.yandex.net/mystem/mystem-3.0-win7-64bit.zip
---------------------------------------------------------------------------
BadZipFile Traceback (most recent call last)
<ipython-input-2-489909c69c84> in <module>()
----> 1 m = Mystem()
`C:\Program Files\Anaconda3\lib\site-packages\pymystem3\mystem.py in __init__(sel` `f, mystem_bin, grammar_info, disambiguation, entire_input)` ` 177` ` 178 if self._mystem_bin is None:` `--> 179 autoinstall()` ` 180 self._mystem_bin = MYSTEM_BIN` ` 181`
C:\Program Files\Anaconda3\lib\site-packages\pymystem3\mystem.py in autoinstall(
out)
59 if os.path.isfile(MYSTEM_BIN):
60 return
---> 61 install(out)
62
63
`C:\Program Files\Anaconda3\lib\site-packages\pymystem3\mystem.py in install(out)`
95 elif url.endswith('.zip'):
96 import zipfile
---> 97 zip = zipfile.ZipFile(tmp_path)
98 try:
99 zip.extractall(MYSTEM_DIR)
`C:\Program Files\Anaconda3\lib\zipfile.py in __init__(self, file, mode, compress` `ion, allowZip64)` ` 1024 try:` ` 1025 if mode == 'r':` `-> 1026 self._RealGetContents()` ` 1027 elif mode in ('w', 'x'):` ` 1028 # set the modified flag so central directory gets writte` `n`
C:\Program Files\Anaconda3\lib\zipfile.py in _RealGetContents(self)
1091 raise BadZipFile("File is not a zip file")
1092 if not endrec:
-> 1093 raise BadZipFile("File is not a zip file")
1094 if self.debug > 1:
1095 print(endrec)
`BadZipFile: File is not a zip file`
In [3]:
That's because network security tools replaced actual zip content with some kind of error page, 'You are prohibited to do this, bla bla bla'. How can I do installation in offline mode?
Fixed with local http file server and changes in hosts
file (redirected yandex.net to localhost). But this is more like workaround.
Currenly, offline mode is not supported indeed: you need to be able to download the resources. Do you have any ideas how to address it?
@alexanderpanchenko it can be solved for example via including actual version of all required libraries into package (without dropping an ability to upgrade them). Or maybe exception during installation can be cought and replaced with the information about manual installitaion?
@QtRoS
Hm, maybe i miss the point, but the Mystem's constructor have a argument 'mystem_bin', so
m = Mystem(mystem_bin='C://path_to_preloaded/mystem.exe')
should work for you (you also have an option to set up envvar MYSTEM3_PATH).
Hello, I would close the issue for now, but a pull request implementing / integrating the mentioned here offline installation functionality is welcome if it is needed.