0

I have problem installing gensim module. I installed numpy and scipy dependent modules successfully but was getting error while installing gensim. I tried solutions given in Python pip install gives "Command "python setup.py egg_info" failed with error code 1" but none of them worked.

Here is the error:

    >pip install --target="D:\python\packages" gensim
Collecting gensim
  Using cached gensim-2.3.0-cp36-cp36m-win32.whl
Collecting scipy>=0.18.1 (from gensim)
  Using cached scipy-0.19.1.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\abcde\AppData\Local\Temp\pip-build-hu8lzsjz\scipy\setup.py", line 416, in <module>
        setup_package()
      File "C:\Users\abcde\AppData\Local\Temp\pip-build-hu8lzsjz\scipy\setup.py", line 412, in setup_package
        setup(**metadata)
      File "c:\program files (x86)\python36-32\lib\distutils\core.py", line 108, in setup
        _setup_distribution = dist = klass(attrs)
      File "c:\program files (x86)\python36-32\lib\site-packages\setuptools\dist.py", line 315, in __init__
        self.fetch_build_eggs(attrs['setup_requires'])
      File "c:\program files (x86)\python36-32\lib\site-packages\setuptools\dist.py", line 361, in fetch_build_eggs
        replace_conflicting=True,
      File "c:\program files (x86)\python36-32\lib\site-packages\pkg_resources\__init__.py", line 850, in resolve
        dist = best[req.key] = env.best_match(req, ws, installer)
      File "c:\program files (x86)\python36-32\lib\site-packages\pkg_resources\__init__.py", line 1122, in best_match
        return self.obtain(req, installer)
      File "c:\program files (x86)\python36-32\lib\site-packages\pkg_resources\__init__.py", line 1134, in obtain
        return installer(requirement)
      File "c:\program files (x86)\python36-32\lib\site-packages\setuptools\dist.py", line 429, in fetch_build_egg
        return cmd.easy_install(req)
      File "c:\program files (x86)\python36-32\lib\site-packages\setuptools\command\easy_install.py", line 653, in easy_install
        not self.always_copy, self.local_index
      File "c:\program files (x86)\python36-32\lib\site-packages\setuptools\package_index.py", line 636, in fetch_distribution
        dist = find(requirement)
      File "c:\program files (x86)\python36-32\lib\site-packages\setuptools\package_index.py", line 617, in find
        dist.download_location = self.download(dist.location, tmpdir)
      File "c:\program files (x86)\python36-32\lib\site-packages\setuptools\package_index.py", line 566, in download
        found = self._download_url(scheme.group(1), spec, tmpdir)
      File "c:\program files (x86)\python36-32\lib\site-packages\setuptools\package_index.py", line 805, in _download_url
        return self._attempt_download(url, filename)
      File "c:\program files (x86)\python36-32\lib\site-packages\setuptools\package_index.py", line 811, in _attempt_download
        headers = self._download_to(url, filename)
      File "c:\program files (x86)\python36-32\lib\site-packages\setuptools\package_index.py", line 726, in _download_to
        block = fp.read(bs)
      File "c:\program files (x86)\python36-32\lib\http\client.py", line 449, in read
        n = self.readinto(b)
      File "c:\program files (x86)\python36-32\lib\http\client.py", line 493, in readinto
        n = self.fp.readinto(b)
      File "c:\program files (x86)\python36-32\lib\socket.py", line 586, in readinto
        return self._sock.recv_into(b)
      File "c:\program files (x86)\python36-32\lib\ssl.py", line 1002, in recv_into
        return self.read(nbytes, buffer)
      File "c:\program files (x86)\python36-32\lib\ssl.py", line 865, in read
        return self._sslobj.read(len, buffer)
      File "c:\program files (x86)\python36-32\lib\ssl.py", line 625, in read
        v = self._sslobj.read(len, buffer)
    ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\abcde\AppData\Local\Temp\pip-build-hu8lzsjz\scipy\
crazy_dd
  • 125
  • 1
  • 12

2 Answers2

0

The error text you've supplied indicates the actual problem is (a) involving the attempt to install scipy, on which gensim relies; (b) related to a broken HTTPS connection, indicating a problem with network connectivity (or something blocking the secure-connection).

Also, it's rare to need to specify a --target for pip; if your environment (reachable executables) is correctly set-up, you'd be able to just do pip install gensim. (And if you are installing to a non-default location, you may have issues later when your active environment isn't using the libraries you expected.)

Suggestions:

  • check that you are able to access remote secure websites, like say the homepage of the PyPI repository which pip is using: https://pypi.python.org/pypi
  • try again later; perhaps the network issues were transient
  • try just pip install scipy
  • consider using the conda distribution tool, which tends to be well-optimized for Windows installations. (I generally prefer the miniconda variant, which installs only the minimum set of things you request.)

Also, while Python, gensim, and related packages can work on Windows systems, note that most development/testing on such Python/NLP/ML open-source happens on Linux/OSX systems. As a result, there are often extra installation/configuration issues on Windows, and then there's usually less prior-documented troubleshooting from people who've previously hit the same issues. So if you have choice, such work often goes smoothest on Linux/Unix systems.

gojomo
  • 52,260
  • 14
  • 86
  • 115
  • Thanks for suggestion gojomo, I will use conda distribution. But the doubt I have is I could install scipy succesfully using pip, any idea why is this error coming up again? I used -- target because I don't have permission to write on to C drive. – crazy_dd Sep 13 '17 at 08:03
0

You can install genism by two ways: 1. pip install -U genism

2.install easy_install then

easy_install https://pypi.python.org/packages/source/s/setuptools/setuptools-19.2.tar.gz