CQCL / lambeq

A high-level Python library for Quantum Natural Language Processing
https://cqcl.github.io/lambeq-docs
Apache License 2.0
451 stars 108 forks source link

error during installation #9

Closed mithunpaul08 closed 2 years ago

mithunpaul08 commented 2 years ago

When I try installing using sh <(curl 'https://cqcl.github.io/lambeq/install.sh'), i get the follwing error:

ERROR: Cannot install lambeq[depccg]==0.1.0, lambeq[depccg]==0.1.1 and lambeq[depccg]==0.1.2 because these package versions have conflicting dependencies.

The conflict is caused by:
    lambeq[depccg] 0.1.2 depends on depccg==1.1.0; extra == "depccg"
    lambeq[depccg] 0.1.1 depends on depccg==1.1.0; extra == "depccg"
    lambeq[depccg] 0.1.0 depends on depccg==1.1.0; extra == "depccg"

To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict

ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/user_guide/#fixing-conflicting-dependencies

I am on a 2020 Macbook air (with Apple M1 chip), and using conda with python=3.8.11 . Will any of that be causing the problem?

Thommy257 commented 2 years ago

Hi @mithunpaul08 , unfortunately, the depccg binaries do not support the M1 chip yet. In order to make it work you need to build depccg yourself with some modifications. The following workflow should help:

  1. Clone the depccg package from Github: https://github.com/masashi-y/depccg
  2. Go the the folder and checkout to the correct branch: cd depccg git checkout v1
  3. Navigate to the cpp folder and open the Makefile
  4. Delete the -march=native flag from line 4 and 5 and add -mcpu=apple-m1 to both lines.
  5. cd into the cpp folder and run make. It might happen that you need to install some extra dependencies to make it work (use homebrew).
  6. Activate the virtual environment where you want to install Lambeq in.
  7. cd back into the depccg main directory and run pip install -r requirements.txt and then pip install .

You can now execute the install script again. Just make sure that the environment in which you installed depccg is activated and that you select the option 2. Install in current virtual environment, when the install script ask you to choose a location to install Lambeq.

Let me know if this helps! 👍

mithunpaul08 commented 2 years ago

i got into a clang/LVMM rabbit hole so i am yet to get it to work completely, but this is great advice. Thanks a lot @Thommy257

Thommy257 commented 2 years ago

Which version of clang are you using? I tested it on version 13.0.

mithunpaul08 commented 2 years ago

12.0.5 . I read somewhere that i have to use clang with --mcpu=apple-14 for m1 laptops. However, i don't know how to run a Make file along with specifying clang --mcpu.. Note: all this started when i made all the changes you suggested and clang gave this error:

 clang: error: the clang compiler does not support '-mcpu=apple-m1'
make: *** [utils.o] Error 1

maybe i just have to upgrade the version of clang? do you know how to do it from command line? sorry i have no idea about clang stuff

Thommy257 commented 2 years ago

You should probably update the Command Line Developer tools to get Clang 13.0. Clang 12.x does not support the M1 chip as far as I know.

This should help: https://stackoverflow.com/a/53364628/9751892

mithunpaul08 commented 2 years ago

ok, so i crossed the depcgg issue finally and got it installed. But then,

However, now what happens is, I get an error while unpacking scipy (pasted below) the code goes on a loop of trying to install scipy and numpy from source, and keeps doing that. Did you face this issue? Do you think this might be because my conda environment already had numpy and scipy installed BEFORE i did the depcg installation?

Scipy error:

Processing scipy/stats/_boost/src/binom_ufunc.pyx
  Cythonizing sources
  INFO: lapack_opt_info:
  INFO: lapack_armpl_info:
  INFO: customize UnixCCompiler
  INFO:   libraries armpl_lp64_mp not found in ['/Users/mithunpaul/miniconda3/envs/lambeq/lib', '/usr/lib']
  INFO:   NOT AVAILABLE
  INFO:
  INFO: lapack_mkl_info:
  INFO:   libraries mkl_rt not found in ['/Users/mithunpaul/miniconda3/envs/lambeq/lib', '/usr/lib']
  INFO:   NOT AVAILABLE
  INFO
setup.py:491: UserWarning: Unrecognized setuptools command ('dist_info --egg-base /private/var/folders/nd/fft9nzw56tn7rvwvnthmbv3w0000gn/T/pip-modern-metadata-b18htokr'), proceeding with generating Cython sources and expanding templates
    warnings.warn("Unrecognized setuptools command ('{}'), proceeding with "
  Running from SciPy source directory.
  /private/var/folders/nd/fft9nzw56tn7rvwvnthmbv3w0000gn/T/pip-build-env-m1we9nd4/overlay/lib/python3.8/site-packages/numpy/distutils/system_info.py:1902: UserWarning:
      Lapack (http://www.netlib.org/lapack/) libraries not found.
      Directories to search for the libraries can be specified in the
      numpy/distutils/site.cfg file (section [lapack]) or by setting
      the LAPACK environment variable.
    return getattr(self, '_calc_info_{}'.format(name))()
  /private/var/folders/nd/fft9nzw56tn7rvwvnthmbv3w0000gn/T/pip-build-env-m1we9nd4/overlay/lib/python3.8/site-packages/numpy/distutils/system_info.py:1902: UserWarning:
      Lapack (http://www.netlib.org/lapack/) sources not found.
      Directories to search for the sources can be specified in the
      numpy/distutils/site.cfg file (section [lapack_src]) or by setting
      the LAPACK_SRC environment variable.
    return getattr(self, '_calc_info_{}'.format(name))()
  Traceback (most recent call last):

WARNING: Discarding https://files.pythonhosted.org/packages/61/67/1a654b96309c991762ee9bc39c363fc618076b155fe52d295211cf2536c7/scipy-1.7.3.tar.gz#sha256=ab5875facfdef77e0a47d5fd39ea178b58e60e454a4c85aa1e52fcb80db7babf (from https://pypi.org/simple/scipy/) (requires-python:>=3.7,<3.11). Command errored out with exit status 1: /Users/mithunpaul/miniconda3/envs/lambeq/bin/python3 /Users/mithunpaul/miniconda3/envs/lambeq/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py prepare_metadata_for_build_wheel /var/folders/nd/fft9nzw56tn7rvwvnthmbv3w0000gn/T/tmpzteeoqh7 Check the logs for full command output.
  Using cached scipy-1.7.2.tar.gz (36.1 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... error
  ERROR: Command errored out with exit status 1:
   command: /Users/mithunpaul/miniconda3/envs/lambeq/bin/python3 /Users/mithunpaul/miniconda3/envs/lambeq/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py prepare_metadata_for_build_wheel /var/folders/nd/fft9nzw56tn7rvwvnthmbv3w0000gn/T/tmpynlk0yz7
       cwd: /private/var/folders/nd/fft9nzw56tn7rvwvnthmbv3w0000gn/T/pip-install-uupx7dfs/scipy_39a4f7366c394

Qn2) sh<(curl 'https://cqcl.github.io/lambeq/install.sh') is still the best method to install lambeq right? I even tried building from source code , but i hit the same error below

Error when installing after conda clean:

Collecting lambeq[depccg]
  Using cached lambeq-0.1.1-py3-none-any.whl (35 kB)
  Using cached lambeq-0.1.0-py3-none-any.whl (31 kB)
ERROR: Cannot install lambeq[depccg]==0.1.0, lambeq[depccg]==0.1.1 and lambeq[depccg]==0.1.2 because these package versions have conflicting dependencies.

The conflict is caused by:
    lambeq[depccg] 0.1.2 depends on pytket>=0.10.0
    lambeq[depccg] 0.1.1 depends on pytket>=0.10.0
    lambeq[depccg] 0.1.0 depends on pytket>=0.10.0

To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict

ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/user_guide/#fixing-conflicting-dependencies
Downloading pre-trained depccg parser...
Traceback (most recent call last):
  File "/Users/mithunpaul/miniconda3/envs/lambeq/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Users/mithunpaul/miniconda3/envs/lambeq/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Users/mithunpaul/research/depccg/depccg/__main__.py", line 8, in <module>
    from .parser import EnglishCCGParser, JapaneseCCGParser
ModuleNotFoundError: No module named 'depccg.parser'
Installation complete.

PS: if this is all getting into fubar land, i can try finding a mac machine prior to m1 chip

Thommy257 commented 2 years ago

Do you rely on conda or can you also use virtualenv and pip? I suspect that this is a conda issue. Let me investigate this a little further.

Thommy257 commented 2 years ago

Also, lambeq requires pytket which doesn't support python 3.10 yet. You need to downgrade to python 3.9 to make it work.

Thommy257 commented 2 years ago

So, the installer script does not detect conda environments, hence, you also need to install lambeq manually (within your environment). You can try that:

conda install cython numpy
conda install 'lambeq[depccg]'
depccg_en download
mithunpaul08 commented 2 years ago

is there a particular conda channel i need to subscribe to for this? below is the error i get for conda install lambeq. Sorry, am yet to try out the virtualenv option.

(lambeq) Mithuns-MacBook-Air:research mithunpaul$ conda install "lambeq[depccg]"
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.

PackagesNotFoundError: The following packages are not available from current channels:

  - lambeq

Current channels:

  - https://repo.anaconda.com/pkgs/main/osx-arm64
  - https://repo.anaconda.com/pkgs/main/noarch
  - https://repo.anaconda.com/pkgs/r/osx-arm64
  - https://repo.anaconda.com/pkgs/r/noarch

To search for alternate channels that may provide the conda package you're
looking for, navigate to

    https://anaconda.org

and use the search bar at the top of the page.

update: these anaconda searches also returned empty results. did you push it as a private package?

https://anaconda.org/search?q=lambeq

https://anaconda.org/search?q=lambeq%5Bdepccg%5D

Thommy257 commented 2 years ago

If you are required to use a conda environment, you should most likely also be able to use the pip commands to install lambeq (i.e replace conda by pip)

However, don't forget to downgrade to python3.9. It won't work on python3.10.

dimkart commented 2 years ago

@mithunpaul08 We'll soon have release 0.2.0 out (we hope within March) which will include our own fully-integrated parser, so these problems with M1 chip and depccg will be solved once and for all. Let us know if there is anything else to help you with or we can close this issue.

mithunpaul08 commented 2 years ago

you can close this. i haven't really had the chance to try to it sadly. But i dont want to hold up anything. Plus i think by the time i circle back to this v2 will be out solving all my issues...lol