KlangAlpha/Kdata

Building wheel for TA-Lib (setup.py) ... error

Closed this issue · 3 comments

zzg16 commented

执行pip3 install -r requirements.txt报错,详细错误信息如下:

Collecting idna<4,>=2.5
  Downloading idna-3.3-py3-none-any.whl (61 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.2/61.2 kB 4.5 MB/s eta 0:00:00
Collecting certifi>=2017.4.17
  Using cached certifi-2022.5.18.1-py3-none-any.whl (155 kB)
Requirement already satisfied: six>=1.5 in /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages (from python-dateutil>=2.8.1->pandas->-r requirements.txt (line 2)) (1.15.0)
Building wheels for collected packages: TA-Lib
  Building wheel for TA-Lib (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [30 lines of output]
      /private/var/folders/kk/lg3xcm7x5017_7krxv5lt5pr0000gp/T/pip-install-_nkdvnwl/ta-lib_966925a58cd94b80830c182779ca23bd/setup.py:77: UserWarning: Cannot find ta-lib library, installation may fail.
        warnings.warn('Cannot find ta-lib library, installation may fail.')
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/private/var/folders/kk/lg3xcm7x5017_7krxv5lt5pr0000gp/T/pip-install-_nkdvnwl/ta-lib_966925a58cd94b80830c182779ca23bd/setup.py", line 146, in <module>
          setup(
        File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/__init__.py", line 164, in setup
          _install_setup_requires(attrs)
        File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/__init__.py", line 159, in _install_setup_requires
          dist.fetch_build_eggs(dist.setup_requires)
        File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/dist.py", line 699, in fetch_build_eggs
          resolved_dists = pkg_resources.working_set.resolve(
        File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/pkg_resources/__init__.py", line 779, in resolve
          dist = best[req.key] = env.best_match(
        File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/pkg_resources/__init__.py", line 1064, in best_match
          return self.obtain(req, installer)
        File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/pkg_resources/__init__.py", line 1076, in obtain
          return installer(requirement)
        File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/dist.py", line 758, in fetch_build_egg
          return fetch_build_egg(self, req)
        File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/installer.py", line 133, in fetch_build_egg
          wheel.install_as_egg(dist_location)
        File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/wheel.py", line 99, in install_as_egg
          self._install_as_egg(destination_eggdir, zf)
        File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/wheel.py", line 107, in _install_as_egg
          self._convert_metadata(zf, destination_eggdir, dist_info, egg_info)
        File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/wheel.py", line 128, in _convert_metadata
          os.mkdir(destination_eggdir)
      FileExistsError: [Errno 17] File exists: '/private/var/folders/kk/lg3xcm7x5017_7krxv5lt5pr0000gp/T/pip-install-_nkdvnwl/ta-lib_966925a58cd94b80830c182779ca23bd/.eggs/numpy-1.22.4-py3.8-macosx-10.14-x86_64.egg'
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for TA-Lib
  Running setup.py clean for TA-Lib
  error: subprocess-exited-with-error

  × python setup.py clean did not run successfully.
  │ exit code: 1
  ╰─> [30 lines of output]
      /private/var/folders/kk/lg3xcm7x5017_7krxv5lt5pr0000gp/T/pip-install-_nkdvnwl/ta-lib_966925a58cd94b80830c182779ca23bd/setup.py:77: UserWarning: Cannot find ta-lib library, installation may fail.
        warnings.warn('Cannot find ta-lib library, installation may fail.')
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/private/var/folders/kk/lg3xcm7x5017_7krxv5lt5pr0000gp/T/pip-install-_nkdvnwl/ta-lib_966925a58cd94b80830c182779ca23bd/setup.py", line 146, in <module>
          setup(
        File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/__init__.py", line 164, in setup
          _install_setup_requires(attrs)
        File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/__init__.py", line 159, in _install_setup_requires
          dist.fetch_build_eggs(dist.setup_requires)
        File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/dist.py", line 699, in fetch_build_eggs
          resolved_dists = pkg_resources.working_set.resolve(
        File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/pkg_resources/__init__.py", line 779, in resolve
          dist = best[req.key] = env.best_match(
        File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/pkg_resources/__init__.py", line 1064, in best_match
          return self.obtain(req, installer)
        File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/pkg_resources/__init__.py", line 1076, in obtain
          return installer(requirement)
        File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/dist.py", line 758, in fetch_build_egg
          return fetch_build_egg(self, req)
        File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/installer.py", line 133, in fetch_build_egg
          wheel.install_as_egg(dist_location)
        File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/wheel.py", line 99, in install_as_egg
          self._install_as_egg(destination_eggdir, zf)
        File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/wheel.py", line 107, in _install_as_egg
          self._convert_metadata(zf, destination_eggdir, dist_info, egg_info)
        File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/setuptools/wheel.py", line 128, in _convert_metadata
          os.mkdir(destination_eggdir)
      FileExistsError: [Errno 17] File exists: '/private/var/folders/kk/lg3xcm7x5017_7krxv5lt5pr0000gp/T/pip-install-_nkdvnwl/ta-lib_966925a58cd94b80830c182779ca23bd/.eggs/numpy-1.22.4-py3.8-macosx-10.14-x86_64.egg'
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed cleaning build dir for TA-Lib
Failed to build TA-Lib
Installing collected packages: pytz, ply, websockets, urllib3, python-dateutil, pyparsing, pillow, numpy, kiwisolver, idna, fonttools, cycler, charset-normalizer, certifi, TA-Lib, requests, pandas, packaging, matplotlib, baostock
  WARNING: The scripts f2py, f2py3 and f2py3.8 are installed in '/Users/xxxxx/Library/Python/3.8/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The scripts fonttools, pyftmerge, pyftsubset and ttx are installed in '/Users/xxxxx/Library/Python/3.8/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The script normalizer is installed in '/Users/xxxxx/Library/Python/3.8/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  Running setup.py install for TA-Lib ... error
  error: subprocess-exited-with-error

  × Running setup.py install for TA-Lib did not run successfully.
  │ exit code: 1
  ╰─> [28 lines of output]
      /private/var/folders/kk/lg3xcm7x5017_7krxv5lt5pr0000gp/T/pip-install-_nkdvnwl/ta-lib_966925a58cd94b80830c182779ca23bd/setup.py:77: UserWarning: Cannot find ta-lib library, installation may fail.
        warnings.warn('Cannot find ta-lib library, installation may fail.')
      running install
      running build
      running build_py
      creating build
      creating build/lib.macosx-10.14-x86_64-3.8
      creating build/lib.macosx-10.14-x86_64-3.8/talib
      copying talib/abstract.py -> build/lib.macosx-10.14-x86_64-3.8/talib
      copying talib/test_polars.py -> build/lib.macosx-10.14-x86_64-3.8/talib
      copying talib/test_abstract.py -> build/lib.macosx-10.14-x86_64-3.8/talib
      copying talib/deprecated.py -> build/lib.macosx-10.14-x86_64-3.8/talib
      copying talib/__init__.py -> build/lib.macosx-10.14-x86_64-3.8/talib
      copying talib/stream.py -> build/lib.macosx-10.14-x86_64-3.8/talib
      copying talib/test_pandas.py -> build/lib.macosx-10.14-x86_64-3.8/talib
      copying talib/test_data.py -> build/lib.macosx-10.14-x86_64-3.8/talib
      copying talib/test_func.py -> build/lib.macosx-10.14-x86_64-3.8/talib
      copying talib/test_stream.py -> build/lib.macosx-10.14-x86_64-3.8/talib
      running build_ext
      building 'talib._ta_lib' extension
      creating build/temp.macosx-10.14-x86_64-3.8
      creating build/temp.macosx-10.14-x86_64-3.8/talib
      clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -iwithsysroot/System/Library/Frameworks/System.framework/PrivateHeaders -iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/Headers -arch arm64 -arch x86_64 -Werror=implicit-function-declaration -I/usr/include -I/usr/local/include -I/opt/include -I/opt/local/include -I/opt/homebrew/include -I/opt/homebrew/opt/ta-lib/include -I/Users/xxxxx/Library/Python/3.8/lib/python/site-packages/numpy/core/include -I/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/include/python3.8 -c talib/_ta_lib.c -o build/temp.macosx-10.14-x86_64-3.8/talib/_ta_lib.o
      talib/_ta_lib.c:682:10: fatal error: 'ta-lib/ta_defs.h' file not found
      #include "ta-lib/ta_defs.h"
               ^~~~~~~~~~~~~~~~~~
      1 error generated.
      error: command 'clang' failed with exit status 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> TA-Lib

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
➜  Klang git:(main) ✗ pip install TA-Lib
zsh: command not found: pip
➜  Klang git:(main) ✗ pip3 install TA-Lib
Defaulting to user installation because normal site-packages is not writeable
Collecting TA-Lib
  Using cached TA-Lib-0.4.24.tar.gz (269 kB)
  Preparing metadata (setup.py) ... done
Requirement already satisfied: numpy in /Users/xxxxx/Library/Python/3.8/lib/python/site-packages (from TA-Lib) (1.22.4)
Building wheels for collected packages: TA-Lib
  Building wheel for TA-Lib (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [28 lines of output]
      /private/var/folders/kk/lg3xcm7x5017_7krxv5lt5pr0000gp/T/pip-install-_vfkhcuc/ta-lib_a4ac4dcf69bb41ee913e9b0565380946/setup.py:77: UserWarning: Cannot find ta-lib library, installation may fail.
        warnings.warn('Cannot find ta-lib library, installation may fail.')
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.macosx-10.14-x86_64-3.8
      creating build/lib.macosx-10.14-x86_64-3.8/talib
      copying talib/abstract.py -> build/lib.macosx-10.14-x86_64-3.8/talib
      copying talib/test_polars.py -> build/lib.macosx-10.14-x86_64-3.8/talib
      copying talib/test_abstract.py -> build/lib.macosx-10.14-x86_64-3.8/talib
      copying talib/deprecated.py -> build/lib.macosx-10.14-x86_64-3.8/talib
      copying talib/__init__.py -> build/lib.macosx-10.14-x86_64-3.8/talib
      copying talib/stream.py -> build/lib.macosx-10.14-x86_64-3.8/talib
      copying talib/test_pandas.py -> build/lib.macosx-10.14-x86_64-3.8/talib
      copying talib/test_data.py -> build/lib.macosx-10.14-x86_64-3.8/talib
      copying talib/test_func.py -> build/lib.macosx-10.14-x86_64-3.8/talib
      copying talib/test_stream.py -> build/lib.macosx-10.14-x86_64-3.8/talib
      running build_ext
      building 'talib._ta_lib' extension
      creating build/temp.macosx-10.14-x86_64-3.8
      creating build/temp.macosx-10.14-x86_64-3.8/talib
      clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -iwithsysroot/System/Library/Frameworks/System.framework/PrivateHeaders -iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/Headers -arch arm64 -arch x86_64 -Werror=implicit-function-declaration -I/usr/include -I/usr/local/include -I/opt/include -I/opt/local/include -I/opt/homebrew/include -I/opt/homebrew/opt/ta-lib/include -I/Users/xxxxx/Library/Python/3.8/lib/python/site-packages/numpy/core/include -I/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/include/python3.8 -c talib/_ta_lib.c -o build/temp.macosx-10.14-x86_64-3.8/talib/_ta_lib.o
      talib/_ta_lib.c:682:10: fatal error: 'ta-lib/ta_defs.h' file not found
      #include "ta-lib/ta_defs.h"
               ^~~~~~~~~~~~~~~~~~
      1 error generated.
      error: command 'clang' failed with exit status 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for TA-Lib
  Running setup.py clean for TA-Lib
Failed to build TA-Lib
Installing collected packages: TA-Lib
  Running setup.py install for TA-Lib ... error
  error: subprocess-exited-with-error

  × Running setup.py install for TA-Lib did not run successfully.
  │ exit code: 1
  ╰─> [28 lines of output]
      /private/var/folders/kk/lg3xcm7x5017_7krxv5lt5pr0000gp/T/pip-install-_vfkhcuc/ta-lib_a4ac4dcf69bb41ee913e9b0565380946/setup.py:77: UserWarning: Cannot find ta-lib library, installation may fail.
        warnings.warn('Cannot find ta-lib library, installation may fail.')
      running install
      running build
      running build_py
      creating build
      creating build/lib.macosx-10.14-x86_64-3.8
      creating build/lib.macosx-10.14-x86_64-3.8/talib
      copying talib/abstract.py -> build/lib.macosx-10.14-x86_64-3.8/talib
      copying talib/test_polars.py -> build/lib.macosx-10.14-x86_64-3.8/talib
      copying talib/test_abstract.py -> build/lib.macosx-10.14-x86_64-3.8/talib
      copying talib/deprecated.py -> build/lib.macosx-10.14-x86_64-3.8/talib
      copying talib/__init__.py -> build/lib.macosx-10.14-x86_64-3.8/talib
      copying talib/stream.py -> build/lib.macosx-10.14-x86_64-3.8/talib
      copying talib/test_pandas.py -> build/lib.macosx-10.14-x86_64-3.8/talib
      copying talib/test_data.py -> build/lib.macosx-10.14-x86_64-3.8/talib
      copying talib/test_func.py -> build/lib.macosx-10.14-x86_64-3.8/talib
      copying talib/test_stream.py -> build/lib.macosx-10.14-x86_64-3.8/talib
      running build_ext
      building 'talib._ta_lib' extension
      creating build/temp.macosx-10.14-x86_64-3.8
      creating build/temp.macosx-10.14-x86_64-3.8/talib
      clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -iwithsysroot/System/Library/Frameworks/System.framework/PrivateHeaders -iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/Headers -arch arm64 -arch x86_64 -Werror=implicit-function-declaration -I/usr/include -I/usr/local/include -I/opt/include -I/opt/local/include -I/opt/homebrew/include -I/opt/homebrew/opt/ta-lib/include -I/Users/xxxxx/Library/Python/3.8/lib/python/site-packages/numpy/core/include -I/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/include/python3.8 -c talib/_ta_lib.c -o build/temp.macosx-10.14-x86_64-3.8/talib/_ta_lib.o
      talib/_ta_lib.c:682:10: fatal error: 'ta-lib/ta_defs.h' file not found
      #include "ta-lib/ta_defs.h"
               ^~~~~~~~~~~~~~~~~~
      1 error generated.
      error: command 'clang' failed with exit status 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> TA-Lib

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
➜  Klang git:(main) ✗
zzg16 commented

OS: MacOS Monterey 12.3.1

$ brew install ta-lib

zzg16 commented

$ brew install ta-lib

good.