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

Pydantic problems with dependency mismatches #17

Open
0000F8 opened this issue Jan 6, 2024 · 6 comments
Open

Pydantic problems with dependency mismatches #17

0000F8 opened this issue Jan 6, 2024 · 6 comments

Comments

@0000F8
Copy link

0000F8 commented Jan 6, 2024

I get some conflicts where I can't run the main.py script.


ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
spacy 3.3.0 requires pydantic!=1.8,!=1.8.1,<1.9.0,>=1.7.4, but you have pydantic 2.5.3 which is incompatible.
thinc 8.0.17 requires pydantic!=1.8,!=1.8.1,<1.9.0,>=1.7.4, but you have pydantic 2.5.3 which is incompatible.
doc2graph 0.2.0b0.post7+git.99ac9e69 requires pydantic==1.8.2, but you have pydantic 2.5.3 which is incompatible.

then if I install pydantic 1.8.2

I get


ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
dglgo 0.0.2 requires pydantic>=1.9.0, but you have pydantic 1.8.2 which is incompatible.

and back and forth.

[edit]
Here is what I get when I run main.py for set-up.

Traceback (most recent call last):
  File "/Users/z1ggy/projects/forma/doc2graph/src/main.py", line 4, in <module>
    from src.inference import inference
  File "/Users/z1ggy/projects/forma/doc2graph/src/inference.py", line 7, in <module>
    from src.data.feature_builder import FeatureBuilder
  File "/Users/z1ggy/projects/forma/doc2graph/src/data/feature_builder.py", line 3, in <module>
    import spacy
  File "/Users/z1ggy/anaconda3/envs/doc2graph/lib/python3.9/site-packages/spacy/__init__.py", line 14, in <module>
    from . import pipeline  # noqa: F401
  File "/Users/z1ggy/anaconda3/envs/doc2graph/lib/python3.9/site-packages/spacy/pipeline/__init__.py", line 1, in <module>
    from .attributeruler import AttributeRuler
  File "/Users/z1ggy/anaconda3/envs/doc2graph/lib/python3.9/site-packages/spacy/pipeline/attributeruler.py", line 6, in <module>
    from .pipe import Pipe
  File "spacy/pipeline/pipe.pyx", line 8, in init spacy.pipeline.pipe
  File "/Users/z1ggy/anaconda3/envs/doc2graph/lib/python3.9/site-packages/spacy/training/__init__.py", line 11, in <module>
    from .callbacks import create_copy_from_base_model  # noqa: F401
  File "/Users/z1ggy/anaconda3/envs/doc2graph/lib/python3.9/site-packages/spacy/training/callbacks.py", line 3, in <module>
    from ..language import Language
  File "/Users/z1ggy/anaconda3/envs/doc2graph/lib/python3.9/site-packages/spacy/language.py", line 25, in <module>
    from .training.initialize import init_vocab, init_tok2vec
  File "/Users/z1ggy/anaconda3/envs/doc2graph/lib/python3.9/site-packages/spacy/training/initialize.py", line 14, in <module>
    from .pretrain import get_tok2vec_ref
  File "/Users/z1ggy/anaconda3/envs/doc2graph/lib/python3.9/site-packages/spacy/training/pretrain.py", line 16, in <module>
    from ..schemas import ConfigSchemaPretrain
  File "/Users/z1ggy/anaconda3/envs/doc2graph/lib/python3.9/site-packages/spacy/schemas.py", line 216, in <module>
    class TokenPattern(BaseModel):
  File "/Users/z1ggy/anaconda3/envs/doc2graph/lib/python3.9/site-packages/pydantic/main.py", line 299, in __new__
    fields[ann_name] = ModelField.infer(
  File "/Users/z1ggy/anaconda3/envs/doc2graph/lib/python3.9/site-packages/pydantic/fields.py", line 411, in infer
    return cls(
  File "/Users/z1ggy/anaconda3/envs/doc2graph/lib/python3.9/site-packages/pydantic/fields.py", line 342, in __init__
    self.prepare()
  File "/Users/z1ggy/anaconda3/envs/doc2graph/lib/python3.9/site-packages/pydantic/fields.py", line 451, in prepare
    self._type_analysis()
  File "/Users/z1ggy/anaconda3/envs/doc2graph/lib/python3.9/site-packages/pydantic/fields.py", line 545, in _type_analysis
    self._type_analysis()
  File "/Users/z1ggy/anaconda3/envs/doc2graph/lib/python3.9/site-packages/pydantic/fields.py", line 550, in _type_analysis
    if issubclass(origin, Tuple):  # type: ignore
  File "/Users/z1ggy/anaconda3/envs/doc2graph/lib/python3.9/typing.py", line 852, in __subclasscheck__
    return issubclass(cls, self.__origin__)
TypeError: issubclass() arg 1 must be a class

any protips here?

@VimukthiRandika1997
Copy link

VimukthiRandika1997 commented Jan 14, 2024

I got the same issue!

comment out spacy in requirements.txt file, then run the command pip install -e .
After that conda install spacy

You might get an error with opencv, in that case

pip uninstall opencv-contrib-python
pip uninstall opencv-python
pip uninstall opencv-python-headless

pip install opencv-python====4.6.0.66

After all, run python src/main.py --init

@andreagemelli
Copy link
Owner

Sorry for the late answer @0000F8 and thank you @VimukthiRandika1997 for the solution!
I will try again in local, solve the conflicts and push the changes! Leaving the issue open for now, closing with next commit!

@VimukthiRandika1997
Copy link

@andreagemelli Thank you very much!

@0000F8
Copy link
Author

0000F8 commented Jan 26, 2024

Still get

Traceback (most recent call last):
File "/Users/z1ggy/projects/forma/doc2graph/src/main.py", line 4, in
from src.inference import inference
File "/Users/z1ggy/projects/forma/doc2graph/src/inference.py", line 7, in
from src.data.feature_builder import FeatureBuilder
File "/Users/z1ggy/projects/forma/doc2graph/src/data/feature_builder.py", line 3, in
import spacy
File "/Users/z1ggy/anaconda3/envs/doc2graph/lib/python3.9/site-packages/spacy/init.py", line 13, in
from . import pipeline # noqa: F401
File "/Users/z1ggy/anaconda3/envs/doc2graph/lib/python3.9/site-packages/spacy/pipeline/init.py", line 1, in
from .attributeruler import AttributeRuler
File "/Users/z1ggy/anaconda3/envs/doc2graph/lib/python3.9/site-packages/spacy/pipeline/attributeruler.py", line 8, in
from ..language import Language
File "/Users/z1ggy/anaconda3/envs/doc2graph/lib/python3.9/site-packages/spacy/language.py", line 43, in
from .pipe_analysis import analyze_pipes, print_pipe_analysis, validate_attrs
File "/Users/z1ggy/anaconda3/envs/doc2graph/lib/python3.9/site-packages/spacy/pipe_analysis.py", line 6, in
from .tokens import Doc, Span, Token
File "/Users/z1ggy/anaconda3/envs/doc2graph/lib/python3.9/site-packages/spacy/tokens/init.py", line 1, in
from ._serialize import DocBin
File "/Users/z1ggy/anaconda3/envs/doc2graph/lib/python3.9/site-packages/spacy/tokens/_serialize.py", line 14, in
from ..vocab import Vocab
File "spacy/vocab.pyx", line 1, in init spacy.vocab
File "spacy/tokens/doc.pyx", line 49, in init spacy.tokens.doc
File "/Users/z1ggy/anaconda3/envs/doc2graph/lib/python3.9/site-packages/spacy/schemas.py", line 287, in
class TokenPattern(BaseModel):
File "/Users/z1ggy/anaconda3/envs/doc2graph/lib/python3.9/site-packages/pydantic/main.py", line 299, in new
fields[ann_name] = ModelField.infer(
File "/Users/z1ggy/anaconda3/envs/doc2graph/lib/python3.9/site-packages/pydantic/fields.py", line 411, in infer
return cls(
File "/Users/z1ggy/anaconda3/envs/doc2graph/lib/python3.9/site-packages/pydantic/fields.py", line 342, in init
self.prepare()
File "/Users/z1ggy/anaconda3/envs/doc2graph/lib/python3.9/site-packages/pydantic/fields.py", line 451, in prepare
self._type_analysis()
File "/Users/z1ggy/anaconda3/envs/doc2graph/lib/python3.9/site-packages/pydantic/fields.py", line 545, in _type_analysis
self._type_analysis()
File "/Users/z1ggy/anaconda3/envs/doc2graph/lib/python3.9/site-packages/pydantic/fields.py", line 550, in _type_analysis
if issubclass(origin, Tuple): # type: ignore
File "/Users/z1ggy/anaconda3/envs/doc2graph/lib/python3.9/typing.py", line 852, in subclasscheck
return issubclass(cls, self.origin)
TypeError: issubclass() arg 1 must be a class

@0000F8
Copy link
Author

0000F8 commented Jan 27, 2024

Sorry for the late answer @0000F8 and thank you @VimukthiRandika1997 for the solution! I will try again in local, solve the conflicts and push the changes! Leaving the issue open for now, closing with next commit!

Any chance of a timeline?

@0000F8
Copy link
Author

0000F8 commented Jan 27, 2024

Tried this:

conda install -c conda-forge spacy
conda install -c conda-forge pydantic

ended up here:
/Users/z1ggy/anaconda3/envs/doc2graph/lib/python3.9/site-packages/torchvision/io/image.py:13: UserWarning: Failed to load image Python extension: dlopen(/Users/z1ggy/anaconda3/envs/doc2graph/lib/python3.9/site-packages/torchvision/image.so, 0x0006): Symbol not found: (__ZN3c106detail19maybe_wrap_dim_slowExxb)
Referenced from: '/Users/z1ggy/anaconda3/envs/doc2graph/lib/python3.9/site-packages/torchvision/image.so'
Expected in: '/Users/z1ggy/anaconda3/envs/doc2graph/lib/python3.9/site-packages/torch/lib/libc10.dylib'
warn(f"Failed to load image Python extension: {e}")
DGL backend not selected or invalid. Assuming PyTorch for now.
Setting the default backend to "pytorch". You can change it in the ~/.dgl/config.json file or export the DGLBACKEND environment variable. Valid options are: pytorch, mxnet, tensorflow (all lowercase)
Traceback (most recent call last):
File "/Users/z1ggy/projects/forma/doc2graph/src/main.py", line 4, in
from src.inference import inference
File "/Users/z1ggy/projects/forma/doc2graph/src/inference.py", line 8, in
from src.data.graph_builder import GraphBuilder
File "/Users/z1ggy/projects/forma/doc2graph/src/data/graph_builder.py", line 6, in
import dgl
File "/Users/z1ggy/anaconda3/envs/doc2graph/lib/python3.9/site-packages/dgl/init.py", line 14, in
from .backend import backend_name, load_backend # usort: skip
File "/Users/z1ggy/anaconda3/envs/doc2graph/lib/python3.9/site-packages/dgl/backend/init.py", line 122, in
load_backend(get_preferred_backend())
File "/Users/z1ggy/anaconda3/envs/doc2graph/lib/python3.9/site-packages/dgl/backend/init.py", line 57, in load_backend
mod = importlib.import_module(".%s" % mod_name, name)
File "/Users/z1ggy/anaconda3/envs/doc2graph/lib/python3.9/importlib/init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/Users/z1ggy/anaconda3/envs/doc2graph/lib/python3.9/site-packages/dgl/backend/pytorch/init.py", line 2, in
from .tensor import *
File "/Users/z1ggy/anaconda3/envs/doc2graph/lib/python3.9/site-packages/dgl/backend/pytorch/tensor.py", line 16, in
raise RuntimeError("DGL requires PyTorch >= 1.13.0")
RuntimeError: DGL requires PyTorch >= 1.13.0

Performed conda install pytorch

finally got to here:

(doc2graph) ➜ doc2graph git:(master) ✗ python src/main.py --init
/Users/z1ggy/anaconda3/envs/doc2graph/lib/python3.9/site-packages/torchvision/io/image.py:13: UserWarning: Failed to load image Python extension: dlopen(/Users/z1ggy/anaconda3/envs/doc2graph/lib/python3.9/site-packages/torchvision/image.so, 0x0006): Symbol not found: (__ZN2at4_ops19empty_memory_format4callEN3c108ArrayRefIxEENS2_8optionalINS2_10ScalarTypeEEENS5_INS2_6LayoutEEENS5_INS2_6DeviceEEENS5_IbEENS5_INS2_12MemoryFormatEEE)
Referenced from: '/Users/z1ggy/anaconda3/envs/doc2graph/lib/python3.9/site-packages/torchvision/image.so'
Expected in: '/Users/z1ggy/anaconda3/envs/doc2graph/lib/python3.9/site-packages/torch/lib/libtorch_cpu.dylib'
warn(f"Failed to load image Python extension: {e}")
Namespace(init=True, add_geom=False, add_embs=False, add_hist=False, add_visual=False, add_eweights=False, src_data='FUNSD', data_type='img', edge_type='fully', node_granularity='gt', num_polar_bins=8, model='e2e', gpu=-1, test=False, weights=None, inference=False, docs=None)
Downloading FUNSD
100% [..............................................................................] 36590 / 36590Downloading PAU
100% [................................................................................] 7264 / 7264Initialization completed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants