简体   繁体   中英

cannot install fairseq using Anaconda?

I install the package fairseq but it raises some errors as bellow. I'm using Anaconda Prompt to install on the base environment. Could anyone help to fix this problem?? Thanks so much!

(base) PS C:\WINDOWS\system32> pip install fairseq --user
Collecting fairseq
  Using cached fairseq-0.10.1.tar.gz (924 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  ERROR: Command errored out with exit status 1:
   command: 'C:\Users\johnn\Anaconda3\python.exe' 'C:\Users\johnn\Anaconda3\lib\site-packages\pip\_vendor\pep517\_in_process.py' get_requires_for_build_wheel 'C:\Users\johnn\AppData\Local\Temp\tmpr4o1lvo4'
       cwd: C:\Users\johnn\AppData\Local\Temp\pip-install-5efwp00y\fairseq_8f7b526c143c4da7b9cf30edcc3c3ab0
  Complete output (31 lines):
  Traceback (most recent call last):
    File "setup.py", line 214, in <module>
      do_setup(package_data)
    File "setup.py", line 136, in do_setup
      setup(
    File "C:\Users\johnn\AppData\Local\Temp\pip-build-env-8dy_kf5o\overlay\Lib\site-packages\setuptools\__init__.py", line 152, in setup
      _install_setup_requires(attrs)
    File "C:\Users\johnn\AppData\Local\Temp\pip-build-env-8dy_kf5o\overlay\Lib\site-packages\setuptools\__init__.py", line 147, in _install_setup_requires
      dist.fetch_build_eggs(dist.setup_requires)
    File "C:\Users\johnn\AppData\Local\Temp\pip-build-env-8dy_kf5o\overlay\Lib\site-packages\setuptools\build_meta.py", line 60, in fetch_build_eggs
      raise SetupRequirementsError(specifier_list)
  setuptools.build_meta.SetupRequirementsError: ['cython', 'numpy', 'setuptools>=18.0']

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "C:\Users\johnn\Anaconda3\lib\site-packages\pip\_vendor\pep517\_in_process.py", line 280, in <module>
      main()
    File "C:\Users\johnn\Anaconda3\lib\site-packages\pip\_vendor\pep517\_in_process.py", line 263, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "C:\Users\johnn\Anaconda3\lib\site-packages\pip\_vendor\pep517\_in_process.py", line 114, in get_requires_for_build_wheel
      return hook(config_settings)
    File "C:\Users\johnn\AppData\Local\Temp\pip-build-env-8dy_kf5o\overlay\Lib\site-packages\setuptools\build_meta.py", line 149, in get_requires_for_build_wheel
      return self._get_build_requires(
    File "C:\Users\johnn\AppData\Local\Temp\pip-build-env-8dy_kf5o\overlay\Lib\site-packages\setuptools\build_meta.py", line 130, in _get_build_requires
      self.run_setup()
    File "C:\Users\johnn\AppData\Local\Temp\pip-build-env-8dy_kf5o\overlay\Lib\site-packages\setuptools\build_meta.py", line 145, in run_setup
      exec(compile(code, __file__, 'exec'), locals())
    File "setup.py", line 217, in <module>
      os.unlink(fairseq_examples)
  PermissionError: [WinError 5] Access is denied: 'fairseq\\examples'
  ----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\Users\johnn\Anaconda3\python.exe' 'C:\Users\johnn\Anaconda3\lib\site-packages\pip\_vendor\pep517\_in_process.py' get_requires_

my solution is below

git clone https://github.com/pytorch/fairseq
cd fairseq

activate env(that you created existed)
pip install --editable .

TL; DR: conda install fairseq --channel conda-forge


Conda Channels

Unfortunately, fairseq is not in the list of default conda channel. However, you can use

conda install fairseq --channel conda-forge

to install fairseq . The option --channel ( -c for short) specifies the channel (it uses conda-forge in here) for conda to retrieve packages. You get a more detailed description in Conda channels | Conda Dos .

A similar example is when you follow the offical guide to install PyTorch with conda, it gives

conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch

which means you install these 3 packages through channel pytorch .

About fairseq

If you simply would like to use fairseq rather than doing some specialized modifications (eg create an experimental neural network structure for research), conda install is enough. Otherwise, it is recommended to install as @yeonsook kwak said. The option --editable ( -e for short) means you can directly do editions in this pulled repository.

conda install vs pip install

One advantage of doing conda install (instead of pip install ) is that you can share the packages through all conda environments, which may save disk spaces. However, if you would like to install the same package but with different versions in different environments, you should use pip install .

A possible drawback for conda install is the package from external channels may not be the lastest comparing to those from PyPI/offical source.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM