Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'chardet' not appended to requirements #213

Closed
rmiller-sgntr opened this issue Nov 29, 2018 · 12 comments
Closed

'chardet' not appended to requirements #213

rmiller-sgntr opened this issue Nov 29, 2018 · 12 comments

Comments

@rmiller-sgntr
Copy link

rmiller-sgntr commented Nov 29, 2018

Hi, chardet is required in some parts of the code and is supposed to be appended to requirements with this code in setup.py:

requires = ['six', 'pycryptodome', 'sortedcontainers']
if sys.version_info >= (3, 0):
    requires.append('chardet')

Which does not work as I am getting the following error using python 3.6:

File "/home/ronen/reach/reach_venv3.6/lib/python3.6/site-packages/pdfminer/utils.py", line 13, in
import chardet # For str encoding detection in Py3
ModuleNotFoundError: No module named 'chardet'

I suggest using the following fix, add chardet in required array like so:

requires = ['six', 'pycryptodome', 'sortedcontainers', 'chardet; python_version<"3.0"']

And remove the other two lines. Setup-tools supports the python_version<"x.x" syntax.
Until fixed, chardet has to be added manually to requirements on each project.

@tataganesh
Copy link
Member

tataganesh commented Nov 30, 2018

Hi @rmiller-sgntr. Have you tried adding chardet without the version check? Does it still work on python 3.6? I will check whether it works for python 2.7, and if it does, we can do away with the version check.

@rmiller-sgntr
Copy link
Author

rmiller-sgntr commented Nov 30, 2018 via email

@vinayak-mehta
Copy link
Contributor

I'm also getting this error on Python 3.6 and 3.7 (WSL), issue referenced above. I'm not sure why this is happening. When I install pdfminer.six from source using pip (18.1) (pip install .), it installs chardet but when I try to install from PyPI (pip install pdfminer.six), it doesn't.

@rmiller-sgntr
Copy link
Author

rmiller-sgntr commented Dec 1, 2018

I seems to be a mismatch between the global pipenv lock and the actual python env used. You can look here for more details.

@vinayak-mehta
Copy link
Contributor

I'm not using pipenv (don't have it installed) so that seems unrelated.

@vinayak-mehta
Copy link
Contributor

vinayak-mehta commented Dec 5, 2018

@ganeshtata I checked the wheel available on the pdfminer.six PyPI page. The pdfminer.six-20181108.dist-info/METADATA file doesn't have a Requires-Dist entry for chardet (it has those entries for six, pycryptodome and sortedcontainers). Could this be the reason that chardet isn't getting installed when I do pip install pdfminer.six? (It gets installed when I clone the repo and do pip install . since it uses the setup.py in the second case I guess.)

$ pip -version
pip 18.1 from /home/vinayak/.local/share/virtualenvs/camelot-3.6/lib/python3.6/site-packages/pip (python 3.6)

@vinayak-mehta
Copy link
Contributor

I'm not able to figure out the part where Travis is able to install pdfminer.six correctly using pip but I'm not able to do the same on my local machine.

@vinayak-mehta
Copy link
Contributor

I'm not able to figure out the part where Travis is able to install pdfminer.six correctly using pip but I'm not able to do the same on my local machine.

So I figured this out. Looked through the logs of this Travis job (which installs dev requirements for my package). chardet is being installed with requests instead of pdfminer.six which is why the build doesn't fail.

@vinayak-mehta
Copy link
Contributor

As @rmiller-sgntr suggested in the first comment:

Until fixed, chardet has to be added manually to requirements on each project.

I'm adding chardet to install_requires till this is fixed. Sorry for so many comments.

@QuLogic
Copy link

QuLogic commented Dec 9, 2018

The wheel is universal (2 or 3), but the requirements are not; they differ depending on what ran setup.py. It was probably uploaded with Python 2, so the metadata does not include chardet. That's why it works from source, but not from the wheel. Encoding the version-specificity into the requirement instead of conditionally adding it should fix things.

@anacrolix
Copy link

I can confirm I got this error, and it was fixed by manually installing chardet, for Python 3.7.

@pietermarsman
Copy link
Member

Fixed by #219

sthenault pushed a commit to lowatt/pdfss that referenced this issue Jan 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants