pythonvisual-studiopython-packagingcitations

litstudy Package Installation Python


I am Trying to do Co-Citation Network analysis and have to install package called "litstudy" in Python but I am getting an Error installing it in Jupyter and Python 3.10

Link for litstudy package https://nlesc.github.io/litstudy/index.html

In Python 3.10 while installing from Command Prompt getting Error

C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.32.31326\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2 [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: legacy-install-failure

It Gets installed in Jupyter but when I import the package I get error

 import litstudy   
 Traceback (most recent call last):

 File "C:\Users\vibhu\AppData\Local\Programs\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\IPython\core\interactiveshell.py", line 3437, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)

File "<ipython-input-2-b5a65b8eaed7>", line 1, in <module>
import litstudy

File "C:\Users\vibhu\AppData\Local\Programs\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\litstudy\__init__.py", line 1, in <module>
from .sources import *  # noqa: F403,F401


  File "C:\Users\vibhu\AppData\Local\Programs\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\litstudy\sources\__init__.py", line 1, in <module>
from .scopus import search_scopus, refine_scopus, fetch_scopus

 File "C:\Users\vibhu\AppData\Local\Programs\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\litstudy\sources\scopus.py", line 236
if doi := id.doi:

If anyone can Solve this for me i will be really grateful I'm stuck on this for amost a day and need to get started with networking analysis or if you have any other solution like this for Citation Networking


Solution

  • TL;DR

    The long story

    The litstudy package has a huge number of dependencies, several of which need to be compiled. The error message you got indicates that compilation failed for some one them.

    The dependencies wordcloud and fa2 where a problem on my computer when I ran pip install litstudy to reproduce your problem.

    For wordcloud, the exists a pre-compiled Conda bundle for it, available from conda-forge. I recommend using conda (Anaconda3 or Miniconda3, either will do).

    This worked for wordcloud, as recommended by its own readme:

    conda install -c conda-forge wordcloud
    

    For fa2, there was a second problem: when I ran conda install -c conda-forge fa2, I got this message:

    UnsatisfiableError: The following specifications were found
    to be incompatible with the existing python installation in your environment:
    
    Specifications:
    
      - fa2 -> python[version='>=3.6,<3.7.0a0|>=3.7,<3.8.0a0|>=3.8,<3.9.0a0|>=3.9,<3.10.0a0']
    
    Your python: python==3.10.4
    

    which basically says fa2 is not compatible (yet) with Python 3.10. So, you will have to downgrade to a 3.9.x version of Python to use this package.

    So to install litstudy and its dependencies, I just created a Python 3.9.12 environment using conda, and then I was able to install everything.

    The cut-and-pastable solution

    Putting it all together, this worked for me, after installing Miniconda3:

    conda create -n py39 python==3.9.12
    conda activate py39
    conda install -c conda-forge fa2 wordcloud
    pip install litstudy
    

    In that environment, import litstudy works fine.