Pylint: Cannot install pyenchant on Windows due to missing enchant library

Created on 25 Feb 2018  路  21Comments  路  Source: PyCQA/pylint

Steps to reproduce

  1. Use Windows 10 (64 bit)
  2. Run tox according to https://pylint.readthedocs.io/en/latest/development_guide/contribute.html

Current behavior

You get an error saying:

Collecting pyenchant
  Using cached pyenchant-2.0.0.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\Moo\AppData\Local\Temp\pip-build-04lprgtr\pyenchant\setup.py", line 212, in <module>
        import enchant
      File "C:\Users\Moo\AppData\Local\Temp\pip-build-04lprgtr\pyenchant\enchant\__init__.py", line 92, in <module>
        from enchant import _enchant as _e
      File "C:\Users\Moo\AppData\Local\Temp\pip-build-04lprgtr\pyenchant\enchant\_enchant.py", line 145, in <module>
        raise ImportError(msg)
    ImportError: The 'enchant' C library was not found. Please install it via your OS package manager, or use a pre-built binary wheel from PyPI.

Expected behavior

It is expected for all dependencies to install properly. However, checking an issue for the actual pyenchant project says it has been archived: https://github.com/rfk/pyenchant/issues/70

https://rfk.id.au/blog/entry/archiving-open-source-projects/

pylint --version output

pylint 1.7.1

help wanted needs reproduction

All 21 comments

>

Collecting pyenchant

Does this have anything to do with pylint? I'd think it's more of a
missing library that pip needs to link a C extension module.

--
Dan Stromberg

In the repo, tox.ini contains the dependency pyenchant. So tox has been setup to use an archived dependency (also the dependency does not work on Win 10 (64 bit), but that problem would go away if the dependency is removed altogether)

@thernstig Since this library should give you a prebuilt wheel I recommend:

If your pip version(pip --version) is below 9.0 then I recommend upgrading pip so you can get wheels (binary packages):

 pip install --upgrade pip

Then uninstall and reinstall pyenchant:

 pip uninstall pyenchant
 pip install --no-cache-dir pyenchant

@brycepg Thank you, I will try this.

Is it still a problem that pyenchant is being discontinued though?

Since it's a soft dependency, I don't see a problem in it staying. We could just remove pyenchant from tox if it becomes a problem (although we couldn't run the tests then). I think it's good for this issue to exist though.

CC @godfryd @s0undt3ch any interest in maintaining pyenchant?: rfk/pyenchant#129

I agree with Bryce, this is not so ominous as it sounds. pyenchant has a very limited use case in pylint, e.g just the spellcheck, and we're not in the situation where we rely on constant updates the this third party library. As long as what is already out there works for most of the cases, we should be good even if this library will remain unmaintained in the future.

I don't have the free bandwith to maintain a new project. Sorry.

@brycepg Your suggestion did unfortunately not work. Is there anything else I can do? I aim to fix a bug in pylint, so appreciate any help to solve this so I can get started on the real problem.

(venv) ~\Desktop\projects\pylint [bug/epylint_windows_rcfile]> pip uninstall pyenchant
Cannot uninstall requirement pyenchant, not installed
(venv) ~\Desktop\projects\pylint [bug/epylint_windows_rcfile]> pip install --no-cache-dir pyenchant
Collecting pyenchant
  Downloading pyenchant-2.0.0.tar.gz (64kB)
    100% |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅| 71kB 447kB/s
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\Moo\AppData\Local\Temp\pip-build-uo8s1ti1\pyenchant\setup.py", line 212, in <module>
        import enchant
      File "C:\Users\Moo\AppData\Local\Temp\pip-build-uo8s1ti1\pyenchant\enchant\__init__.py", line 92, in <module>
        from enchant import _enchant as _e
      File "C:\Users\Moo\AppData\Local\Temp\pip-build-uo8s1ti1\pyenchant\enchant\_enchant.py", line 145, in <module>
        raise ImportError(msg)
    ImportError: The 'enchant' C library was not found. Please install it via your OS package manager, or use a pre-built binary wheel from PyPI.

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\Moo\AppData\Local\Temp\pip-build-uo8s1ti1\pyenchant\
(venv) ~\Desktop\projects\pylint [bug/epylint_windows_rcfile]> pip --version
pip 9.0.1 from c:\users\Moo\desktop\projects\pylint\venv\lib\site-packages (python 3.6)
(venv) ~\Desktop\projects\pylint [bug/epylint_windows_rcfile]>

I'd just remove pyenchant to run the tox tests

That traceback indicates that the wheel was not installed, but the source package was picked instead. @thernstig can you try to modify tox.ini and add the following in testenv?

install_command = pip install --only-binary {opts} {packages}

From my understanding, only-binary should prefer installing only wheels, but I might be wrong on this one. From my I notice, pyenchant provides wheel packages for Windows, so not sure why this is not working: https://pypi.python.org/pypi/pyenchant/2.0.0

Unfortunately I'm not keen on dropping pyenchant from tox, since we need to run the spelling checker tests. An alternative would be to move the dependency in .travis.yml but this means we'll no longer be able to test the entire set of pylint's tests locally.

Also I'm going to rename the issue to be about not being able to install pyenchant on Windows, rather than pyenchant being archived. There's not much we can do about that, but we'll still be able to use the current PyPi package.

@PCManticore I have two findings. First, I tried to run tox by just removing the pyenchant dependency, as per @brycepg suggestion. This gave the following result. I am guessing this is also another, separate Windows problem really?

============================ 248 tests deselected =============================
========== 857 passed, 107 skipped, 248 deselected in 78.78 seconds ===========
Coverage.py warning: No data was collected. (no-data-collected)
py36 runtests: commands[1] | python -c import os;cov_strip_abspath = open(os.environ['COVERAGE_FILE'], 'r').read().replace('.tox' + os.sep + os.path.relpath('C:\Users\Moo\Desktop\projects\pylint\.tox\py36\Lib\site-packages', 'C:\Users\Moo\Desktop\projects\pylint\.tox') + os.sep, '');open(os.environ['COVERAGE_FILE'], 'w').write(cov_strip_abspath)
  File "<string>", line 1
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
ERROR: InvocationError: "C:\\Users\\Moo\\Desktop\\projects\\pylint\\.tox\\py36\\Scripts\\python.EXE -c import os;cov_strip_abspath = open(os.environ['COVERAGE_FILE'], 'r').read().replace('.tox' + os.sep + os.path.relpath('C:\\Users\\Moo\\Desktop\\projects\\pylint\\.tox\\py36\\Lib\\site-packages', 'C:\\Users\\Moo\\Desktop\\projects\\pylint\\.tox') + os.sep, '');open(os.environ['COVERAGE_FILE'], 'w').write(cov_strip_abspath)"
___________________________________ summary ___________________________________
ERROR:   py36: commands failed
~\Desktop\projects\pylint [bug/epylint_windows_rcfile]> git st

I then did what you suggested. My tox.ini looks like this for the testenv section:

[testenv]
deps =
   https://github.com/PyCQA/astroid/tarball/master#egg=astroid-master-2.0
   coverage
   isort
   mccabe
   pytest
   pytest-xdist
   pyenchant

setenv =
    COVERAGE_FILE = {toxinidir}/.coverage.{envname}

install_command = pip install --only-binary {opts} {packages}

commands =
    python -Wi {envsitepackagesdir}/coverage run -m pytest {envsitepackagesdir}/pylint/test/ {posargs:}

    ; Transform absolute path to relative path
    ; for compatibility with coveralls.io and fix 'source not available' error.
    ; If you can find a cleaner way is welcome
    python -c "import os;cov_strip_abspath = open(os.environ['COVERAGE_FILE'], 'r').read().replace('.tox' + os.sep + os.path.relpath('{envsitepackagesdir}', '{toxworkdir}') + os.sep, '');open(os.environ['COVERAGE_FILE'], 'w').write(cov_strip_abspath)"
changedir = {toxworkdir}

This gave this output:

~\Desktop\projects\pylint [bug/epylint_windows_rcfile]> tox -epy36
GLOB sdist-make: C:\Users\Moo\Desktop\projects\pylint\setup.py
py36 create: C:\Users\Moo\Desktop\projects\pylint\.tox\py36
py36 installdeps: https://github.com/PyCQA/astroid/tarball/master#egg=astroid-master-2.0, coverage, isort, mccabe, pytest, pytest-xdist, pyenchant
ERROR: invocation failed (exit code 1), logfile: C:\Users\Moo\Desktop\projects\pylint\.tox\py36\log\py36-1.log
ERROR: actionid: py36
msg: getenv
cmdargs: ['C:\\Users\\Moo\\Desktop\\projects\\pylint\\.tox\\py36\\Scripts\\pip.EXE', 'install', '--only-binary', 'https://github.com/PyCQA/astroid/tarball/master#egg=astroid-master-2.0', 'coverage', 'isort', 'mccabe', 'pytest', 'pytest-xdist', 'pyenchant']

Collecting coverage
  Using cached coverage-4.5.1-cp36-cp36m-win_amd64.whl
Collecting isort
  Using cached isort-4.3.4-py3-none-any.whl
Collecting mccabe
  Using cached mccabe-0.6.1-py2.py3-none-any.whl
Collecting pytest
  Using cached pytest-3.4.2-py2.py3-none-any.whl
Collecting pytest-xdist
  Using cached pytest_xdist-1.22.2-py2.py3-none-any.whl
Collecting pyenchant
  Using cached pyenchant-2.0.0.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\Moo\AppData\Local\Temp\pip-build-z3_7pfz0\pyenchant\setup.py", line 212, in <module>
        import enchant
      File "C:\Users\Moo\AppData\Local\Temp\pip-build-z3_7pfz0\pyenchant\enchant\__init__.py", line 92, in <module>
        from enchant import _enchant as _e
      File "C:\Users\Moo\AppData\Local\Temp\pip-build-z3_7pfz0\pyenchant\enchant\_enchant.py", line 145, in <module>
        raise ImportError(msg)
    ImportError: The 'enchant' C library was not found. Please install it via your OS package manager, or use a pre-built binary wheel from PyPI.

So still no difference. I suppose I am the only person crazy enough to have tried to contribute to pylint in a Windows environment?

@thernstig that indeed looks like a separate problem. Can you please report it in a separate issue?

Regarding the fix, I see you are running with python 3.6, but there is no pyenchant wheel for 3.6 (https://pypi.python.org/pypi/pyenchant/2.0.0). If you can test it with a 3.5 or 2.7, does it still reproduce?

Regarding your last statement, don't worry! Up to a couple of years ago, I was also contributing to pylint on a Windows environment, so it's definitely not something too crazy. We even have AppVeyor set up, which now makes me curious why is that working. Maybe we can check what's happening there.

@PCManticore No problem. See here: #1930

(might I also recommend that you add a "python versions" to the default issue template, as in cases like this it is important I assume?)

After some fiddling with installing python 3.5 I managed to test it. It still gives the same error:

~\Desktop\projects\pylint [bug/epylint_windows_rcfile]> tox -epy35
GLOB sdist-make: C:\Users\Moo\Desktop\projects\pylint\setup.py
py35 create: C:\Users\Moo\Desktop\projects\pylint\.tox\py35
py35 installdeps: https://github.com/PyCQA/astroid/tarball/master#egg=astroid-master-2.0, coverage, isort, mccabe, pytest, pytest-xdist, pyenchant
ERROR: invocation failed (exit code 1), logfile: C:\Users\Moo\Desktop\projects\pylint\.tox\py35\log\py35-1.log
ERROR: actionid: py35
msg: getenv
cmdargs: ['C:\\Users\\Moo\\Desktop\\projects\\pylint\\.tox\\py35\\Scripts\\pip.EXE', 'install', 'https://github.com/PyCQA/astroid/tarball/master#egg=astroid-master-2.0', 'coverage', 'isort', 'mccabe', 'pytest', 'pytest-xdist', 'pyenchant']

Collecting astroid-master-2.0 from https://github.com/PyCQA/astroid/tarball/master#egg=astroid-master-2.0
  Downloading https://github.com/PyCQA/astroid/tarball/master (278kB)
  Running setup.py (path:C:\Users\Moo\AppData\Local\Temp\pip-build-tgp3ib1d\astroid-master-2.0\setup.py) egg_info for package astroid-master-2.0 produced metadata for project name astroid. Fix your #egg=astroid-master-2.0
fragments.
Collecting coverage
  Using cached coverage-4.5.1-cp35-cp35m-win_amd64.whl
Collecting isort
  Using cached isort-4.3.4-py3-none-any.whl
Collecting mccabe
  Using cached mccabe-0.6.1-py2.py3-none-any.whl
Collecting pytest
  Using cached pytest-3.4.2-py2.py3-none-any.whl
Collecting pytest-xdist
  Using cached pytest_xdist-1.22.2-py2.py3-none-any.whl
Collecting pyenchant
  Using cached pyenchant-2.0.0.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\Moo\AppData\Local\Temp\pip-build-tgp3ib1d\pyenchant\setup.py", line 212, in <module>
        import enchant
      File "C:\Users\Moo\AppData\Local\Temp\pip-build-tgp3ib1d\pyenchant\enchant\__init__.py", line 92, in <module>
        from enchant import _enchant as _e
      File "C:\Users\Moo\AppData\Local\Temp\pip-build-tgp3ib1d\pyenchant\enchant\_enchant.py", line 145, in <module>
        raise ImportError(msg)
    ImportError: The 'enchant' C library was not found. Please install it via your OS package manager, or use a pre-built binary wheel from PyPI.

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\Moo\AppData\Local\Temp\pip-build-tgp3ib1d\pyenchant\

ERROR: could not install deps [https://github.com/PyCQA/astroid/tarball/master#egg=astroid-master-2.0, coverage,
isort, mccabe, pytest, pytest-xdist, pyenchant]; v = InvocationError('C:\\Users\\Moo\\Desktop\\projects\\pylint\\.tox\\py35\\Scripts\\pip.EXE install https://github.com/PyCQA/astroid/tarball/master#egg=astroid-master-2.0 coverage isort mccabe pytest pytest-xdist pyenchant (see C:\\Users\\Moo\\Desktop\\projects\\pylint\\.tox\\py35\\log\\py35-1.log)', 1)
___________________________________ summary ___________________________________
ERROR:   py35: could not install deps [https://github.com/PyCQA/astroid/tarball/master#egg=astroid-master-2.0, coverage, isort, mccabe, pytest, pytest-xdist, pyenchant]; v = InvocationError('C:\\Users\\Moo\\Desktop\\projects\\pylint\\.tox\\py35\\Scripts\\pip.EXE install https://github.com/PyCQA/astroid/tarball/master#egg=astroid-master-2.0 coverage isort mccabe pytest pytest-xdist pyenchant (see C:\\Users\\Moo\\Desktop\\projects\\pylint\\.tox\\py35\\log\\py35-1.log)', 1)

I'm seeing win32 wheels. I wonder if win32 wheels can be used on a 64-bit python.
@thernstig what does python --version give?

@brycepg Yes I am using the 64-bit versions of Python. I tested tox with:

Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 18:41:36) [MSC v.1900 64 bit (AMD64)] on win32
Python 3.5.4 (v3.5.4:3f56838, Aug 8 2017, 02:17:05) [MSC v.1900 64 bit (AMD64)] on win32

I'll try to find my Windows HDD to repro this issue soon

I can reproduce the pyenchant error for 64 bit python on windows. If you use 32 bit python you will not have the error since there is a wheel for win32.
@PCManticore I think pylint is using 32 bit python on AppVeyor

In case it helps, I had a similar problem on Arch Linux and have resolved it. TL;DR: You may need to install older or multiple versions of the enchant C library.

Steps to reproduce

  1. run git clone https://github.com/PyCQA/pylint.git
  2. run cd pylint/
  3. run python -m tox -epy36

Expected behavior

The /home/me/git/reproduce/pylint/.tox/py36/bin/pip install pyenchant portion of the installation of dependencies runs successfully and tests run.

Behavior before resolving

Command line output had this:
```Collecting pyenchant
Using cached https://files.pythonhosted.org/packages/9e/54/04d88a59efa33fefb88133ceb638cdf754319030c28aadc5a379d82140ed/pyenchant-2.0.0.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
File "/tmp/pip-install-0edndh6k/pyenchant/setup.py", line 212, in
import enchant
File "/tmp/pip-install-0edndh6k/pyenchant/enchant/__init__.py", line 92, in
from enchant import _enchant as _e
File "/tmp/pip-install-0edndh6k/pyenchant/enchant/_enchant.py", line 145, in
raise ImportError(msg)
ImportError: The 'enchant' C library was not found. Please install it via your OS package manager, or use a pre-built binary wheel from PyPI.


I noticed that `/home/me/git/reproduce/pylint/.tox/py36/bin/pip install pyenchant` gives me the same output. I also noticed that Pacman was telling me that the [extra/enchant 2.2.3-1](https://www.archlinux.org/packages/extra/x86_64/enchant/) package was already installed, which I found puzzling.

Before resolving the issue, I had also confirmed the [community/python-pyenchant](https://www.archlinux.org/packages/community/any/python-pyenchant/) package was already installed on my system and I haven't looked closely enough to understand why it was ignored.

### Steps that resolved the behavior for me

1. Install the [aur/enchant1.6](https://aur.archlinux.org/packages/enchant1.6/) package with `pacaur -S aur/enchant1.6`
2. Run `/home/me/git/reproduce/pylint/.tox/py36/bin/pip install pyenchant` successfully

### pylint --version output

``` ~/git/pylint > pylint --version
Using config file /home/me/git/pylint/pylintrc
pylint 1.8.4, 
astroid 1.6.3
Python 3.6.5 (default, Apr 14 2018, 13:17:30) 
[GCC 7.3.1 20180406]

I am using arch linux and I am facing the same issue as @jackieh when running tox. The problem is that enchant package changed its name to enchant-2. Due to that pyenchant doesn't discover C lib because arch linux's name of the package is not in the list of possible names. This issue was reported here https://github.com/rfk/pyenchant/issues/125 but pyenchant owner doesn't maintain it anymore and is not going to address it.

Is pyenchant really necessary? atm it blocks dev of pylint on arch linux. Should I open another issue just for arch linux case?

@kczapla pyenchant is not necessary for the entire pylint run, just for a single checker that implements spelling checks. We'll probably need to move it to an optional dependency at this point.

Hey folks, now if you run tox -e py<version> we'll no longer require pyenchant. Instead we have a separate tox step for it, tox -e spelling, which is only enabled in our CI.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lancelote picture lancelote  路  3Comments

glmdgrielson picture glmdgrielson  路  3Comments

sambarluc picture sambarluc  路  3Comments

pylint-bot picture pylint-bot  路  3Comments

PCManticore picture PCManticore  路  3Comments