Installation issues due to PyPI version of dataclasses
epwalsh opened this issue · comments
After installing the latest build with PyTorch 1.7 in a Python 3.7 or 3.8 environment, I'm getting this error after running allennlp test-install
:
$> allennlp test-install
Traceback (most recent call last):
File "/usr/local/bin/allennlp", line 5, in <module>
from allennlp.__main__ import run
File "/usr/local/lib/python3.8/site-packages/allennlp/__main__.py", line 30, in <module>
from allennlp.commands import main # noqa
File "/usr/local/lib/python3.8/site-packages/allennlp/commands/__init__.py", line 9, in <module>
from allennlp.commands.build_vocab import BuildVocab
File "/usr/local/lib/python3.8/site-packages/allennlp/commands/build_vocab.py", line 14, in <module>
from allennlp.commands.subcommand import Subcommand
File "/usr/local/lib/python3.8/site-packages/allennlp/commands/subcommand.py", line 10, in <module>
from allennlp.common import Registrable
File "/usr/local/lib/python3.8/site-packages/allennlp/common/__init__.py", line 1, in <module>
from allennlp.common.from_params import FromParams
File "/usr/local/lib/python3.8/site-packages/allennlp/common/from_params.py", line 22, in <module>
from allennlp.common.lazy import Lazy
File "/usr/local/lib/python3.8/site-packages/allennlp/common/lazy.py", line 4, in <module>
from allennlp.common.params import Params
File "/usr/local/lib/python3.8/site-packages/allennlp/common/params.py", line 33, in <module>
from allennlp.common.file_utils import cached_path
File "/usr/local/lib/python3.8/site-packages/allennlp/common/file_utils.py", line 545, in <module>
class _Meta:
File "/usr/local/lib/python3.8/site-packages/dataclasses.py", line 958, in dataclass
return wrap(_cls)
File "/usr/local/lib/python3.8/site-packages/dataclasses.py", line 950, in wrap
return _process_class(cls, init, repr, eq, order, unsafe_hash, frozen)
File "/usr/local/lib/python3.8/site-packages/dataclasses.py", line 800, in _process_class
cls_fields = [_get_field(cls, name, type)
File "/usr/local/lib/python3.8/site-packages/dataclasses.py", line 800, in <listcomp>
cls_fields = [_get_field(cls, name, type)
File "/usr/local/lib/python3.8/site-packages/dataclasses.py", line 659, in _get_field
if (_is_classvar(a_type, typing)
File "/usr/local/lib/python3.8/site-packages/dataclasses.py", line 550, in _is_classvar
return type(a_type) is typing._ClassVar
AttributeError: module 'typing' has no attribute '_ClassVar'
The issue only happens when the PyPI version of dataclasses
is installed. The thing is, it shouldn't be installed when using Python >= 3.7, but it is because PyTorch 1.7 lists dataclasses
as an unconditional dependency. This has since been fixed in PyTorch, i.e. dataclasses
is now properly listed as a conditional dependency for Python < 3.7, so with the next PyTorch release we shouldn't see this issue.
For now I think the best we can do is keep this issue open so other people can find it and add a note in the README that you should pip uninstall -y dataclasses
if using Python >= 3.7. I made a PR for that: #4754
pip uninstall -y dataclasses
WORKED FOR ME, THANKS!
Please add in official docs pip install section as this predictably fails on latest versions of python.
allennlp is very nice. the community and team are great!
Hi @BinarySwami-10, I did add a note about this in the README (#4754), but if there's somewhere we could display it, let me know.
Hi @BinarySwami-10, I did add a note about this in the README (#4754), but if there's somewhere we could display it, let me know.
hello @epwalsh !
if im correct,
you added a run command 'pip uninstall -y dataclasses' after installing core package in .github/workflow/ docker's .yml file.
what im saying is this error appeared for non docker installation which i did.
i ran docker on AWS but i ran out of memory, had other technical difficulties, so i made a proxy server to my local computer using nginx .
on my local computer (WINDOWS10,16GB RAM,i5) i used the method mentioned in "demo.allennlp" website where 2 simple pip commands were given. subsequently first ran into an error regarding pytorch version, however i uninstalled and reinstalled pytorch and few other modules (numpy,...other ML related).
but googling AttributeError: module 'typing' has no attribute '_ClassVar'
was the tricky part , all were github errors, google search link i really couldnt understand until i went through all logs and analyzed myself.
even the jsonnet was causing errors, somehow there is sufficient info on web regarding it.
btw uninstalling and reinstalling is producing same error, do recheck on windows10, python 3.7.0. and im too afraid to do it again. kindly verify on other devices.
TLDR:
where ever in the website , if installation process is given like : installation using (pip allen.*) or (docker build -abcd...)
please add a "possible errors during setup" section beside it, based on errors mentioned by users. it will save tremendous time. thank you.
You're talking about changing the "Installing AllenNLP" section in the demo? Those steps are sadly different from model to model (at least in principle. In practice they might all be the same right now.). Also, I really like the convenience of having everything I need to copy&paste in one place on the demo. Since this data classes
issue is going to go away shortly, and ReViz is already working on the demo, I don't think we should do anything about this right now.
@epwalsh this is just a friendly ping to make sure you haven't forgotten about this issue 😜
@epwalsh this is just a friendly ping to make sure you haven't forgotten about this issue 😜
This has been fixed in PyTorch 1.7.1.