petermr / docanalysis

Semantic analysis of text documents including sentence and paragraph splitting
Apache License 2.0
12 stars 3 forks source link

docanalysis crashes on startup on Macos (`typer` needs upgrading) #39

Open petermr opened 5 months ago

petermr commented 5 months ago

Launching docanalysis with --help crashes on Macos. Typical output:

  Stored in directory: /Users/pm286/Library/Caches/pip/wheels/18/49/fb/7c16dc308049458b0d69715b43e85d9460e163b4198dbb4a55
Successfully built docanalysis
Installing collected packages: docanalysis
Successfully installed docanalysis-0.3.0
(base) pm286macbook-2:~ pm286$ docanalysis --version
Traceback (most recent call last):
  File "/opt/anaconda3/bin/docanalysis", line 5, in <module>
    from docanalysis.docanalysis import main
  File "/opt/anaconda3/lib/python3.8/site-packages/docanalysis/__init__.py", line 4, in <module>
    from docanalysis.entity_extraction import EntityExtraction
  File "/opt/anaconda3/lib/python3.8/site-packages/docanalysis/entity_extraction.py", line 6, in <module>
    import spacy
  File "/opt/anaconda3/lib/python3.8/site-packages/spacy/__init__.py", line 14, in <module>
    from .cli.info import info  # noqa: F401
  File "/opt/anaconda3/lib/python3.8/site-packages/spacy/cli/__init__.py", line 3, in <module>
    from ._util import app, setup_cli  # noqa: F401
  File "/opt/anaconda3/lib/python3.8/site-packages/spacy/cli/_util.py", line 8, in <module>
    import typer
  File "/opt/anaconda3/lib/python3.8/site-packages/typer/__init__.py", line 12, in <module>
    from click.termui import get_terminal_size as get_terminal_size
ImportError: cannot import name 'get_terminal_size' from 'click.termui' (/opt/anaconda3/lib/python3.8/site-packages/click/termui.py)
(base) pm286macbook-2:~ pm286$ docanalysis --help
Traceback (most recent call last):
  File "/opt/anaconda3/bin/docanalysis", line 5, in <module>
    from docanalysis.docanalysis import main
  File "/opt/anaconda3/lib/python3.8/site-packages/docanalysis/__init__.py", line 4, in <module>
    from docanalysis.entity_extraction import EntityExtraction
  File "/opt/anaconda3/lib/python3.8/site-packages/docanalysis/entity_extraction.py", line 6, in <module>
    import spacy
  File "/opt/anaconda3/lib/python3.8/site-packages/spacy/__init__.py", line 14, in <module>
    from .cli.info import info  # noqa: F401
  File "/opt/anaconda3/lib/python3.8/site-packages/spacy/cli/__init__.py", line 3, in <module>
    from ._util import app, setup_cli  # noqa: F401
  File "/opt/anaconda3/lib/python3.8/site-packages/spacy/cli/_util.py", line 8, in <module>
    import typer
  File "/opt/anaconda3/lib/python3.8/site-packages/typer/__init__.py", line 12, in <module>
    from click.termui import get_terminal_size as get_terminal_size
ImportError: cannot import name 'get_terminal_size' from 'click.termui' (/opt/anaconda3/lib/python3.8/site-packages/click/termui.py)
(base) pm286macbook-2:~ pm286$ 

I have uninstalled and reinstalled docanalysis

(Renu and Amit do not have these problems on Windows)

petermr commented 5 months ago

I solved this by reinstalling typer

 pip install typer --upgrade
Requirement already satisfied: typer in /opt/anaconda3/lib/python3.8/site-packages (0.3.2)
Collecting typer
  Downloading typer-0.9.0-py3-none-any.whl.metadata (14 kB)
Requirement already satisfied: click<9.0.0,>=7.1.1 in /opt/anaconda3/lib/python3.8/site-packages (from typer) (7.1.2)
Requirement already satisfied: typing-extensions>=3.7.4.3 in /opt/anaconda3/lib/python3.8/site-packages (from typer) (4.1.1)
Downloading typer-0.9.0-py3-none-any.whl (45 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 45.9/45.9 kB 1.4 MB/s eta 0:00:00
Installing collected packages: typer
  Attempting uninstall: typer
    Found existing installation: typer 0.3.2
    Uninstalling typer-0.3.2:
      Successfully uninstalled typer-0.3.2
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.0.7 requires typer<0.4.0,>=0.3.0, but you have typer 0.9.0 which is incompatible.
Successfully installed typer-0.9.0
(base) pm286macbook-2:~ pm286$ docanalysis --help
/opt/anaconda3/lib/python3.8/site-packages/_distutils_hack/__init__.py:26: UserWarning: Setuptools is replacing distutils.
  warnings.warn("Setuptools is replacing distutils.")
usage: docanalysis [-h] [--run_pygetpapers] [--make_section] [-q QUERY] [-k HITS] [--project_name PROJECT_NAME]
                   [-d [DICTIONARY [DICTIONARY ...]]] [-o OUTPUT] [--make_ami_dict MAKE_AMI_DICT]
                   [--search_section [SEARCH_SECTION [SEARCH_SECTION ...]]] [--entities [ENTITIES [ENTITIES ...]]]
                   [--spacy_model SPACY_MODEL] [--html HTML] [--synonyms SYNONYMS] [--make_json MAKE_JSON] [--search_html]
                   [--extract_abb EXTRACT_ABB] [-l LOGLEVEL] [-f LOGFILE]

Welcome to docanalysis version 0.3.0. -h or --help for help

optional arguments:
  -h, --help            show this help message and exit
  --run_pygetpapers     [Command] downloads papers from EuropePMC via pygetpapers
  --make_section        [Command] makes sections; requires a fulltext.xml in CTree directories
  -q QUERY, --query QUERY
                        [pygetpapers] query string
  -k HITS, --hits HITS  [pygetpapers] number of papers to download
  --project_name PROJECT_NAME
                        CProject directory name
  -d [DICTIONARY [DICTIONARY ...]], --dictionary [DICTIONARY [DICTIONARY ...]]
                        [file name/url] existing ami dictionary to annotate sentences or support supervised entity extraction
  -o OUTPUT, --output OUTPUT
                        outputs csv with sentences/terms
  --make_ami_dict MAKE_AMI_DICT
                        [Command] title for ami-dict. Makes ami-dict of all extracted entities; works only with spacy
  --search_section [SEARCH_SECTION [SEARCH_SECTION ...]]
                        [NER/dictionary search] section(s) to annotate. Choose from: ALL, ACK, AFF, AUT, CON, DIS, ETH, FIG,
                        INT, KEY, MET, RES, TAB, TIL. Defaults to ALL
  --entities [ENTITIES [ENTITIES ...]]
                        [NER] entities to extract. Default (ALL). Common entities SpaCy: GPE, LANGUAGE, ORG, PERSON (for
                        additional ones check: );
  --spacy_model SPACY_MODEL
                        [NER] optional.
  --html HTML           outputs html with sentences/terms
  --synonyms SYNONYMS   annotate the corpus/sections with synonyms from ami-dict
  --make_json MAKE_JSON
                        outputs json with sentences/terms
  --search_html         searches html documents (mainly IPCC)
  --extract_abb EXTRACT_ABB
                        [Command] title for abb-ami-dict. Extracts abbreviations and expansions; makes ami-dict of all
                        extracted entities
  -l LOGLEVEL, --loglevel LOGLEVEL
                        provide logging level. Example --log warning <<info,warning,debug,error,critical>>, default='info'
  -f LOGFILE, --logfile LOGFILE
                        saves log to specified file in output directory as well as printing to terminal
(base) pm286macbook-2:~ pm286$