Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation Hangs with " Building wheel for TA-Lib (setup.py) ... /" #386

Closed
0zd3m1r opened this issue Jan 15, 2021 · 28 comments
Closed

Installation Hangs with " Building wheel for TA-Lib (setup.py) ... /" #386

0zd3m1r opened this issue Jan 15, 2021 · 28 comments

Comments

@0zd3m1r
Copy link

0zd3m1r commented Jan 15, 2021

I am facing installation hangs for talib. How can i solve it?

root@******:/home/Python# pip install TA-Lib
Collecting` TA-Lib
Using cached https://files.pythonhosted.org/packages/ac/cf681911aa31e04ba171ab4d523a412f4a746e30d3eacb1738799d181e028b/TA-Lib-0.4.19.tar.gz
Requirement already satisfied: numpy in /usr/local/lib/python3.8/dist-packages (from TA-Lib) (1.19.5)
Building wheels for collected packages: TA-Lib
Building wheel for TA-Lib (setup.py) ... /

@mrjbq7
Copy link
Collaborator

mrjbq7 commented Jan 15, 2021

Not enough information provided, sorry.

@0zd3m1r
Copy link
Author

0zd3m1r commented Jan 15, 2021

I can’t install TA-Lib my friend. Stuck at “ Building wheel for TA-Lib (setup.py) ... /” stage and not progressing any way.

OS: Linux/Debian
Kernel Release: 5.4.0-62-generic
Machine: 64bit

Python version: Python 3.8.5
Pip version: Pip 19.2

@mrjbq7
Copy link
Collaborator

mrjbq7 commented Jan 15, 2021 via email

@0zd3m1r
Copy link
Author

0zd3m1r commented Jan 15, 2021

This method is also stuck at this stage.

running install
running bdist_egg
running egg_info
creating TA_Lib.egg-info
writing TA_Lib.egg-info/PKG-INFO
writing dependency_links to TA_Lib.egg-info/dependency_links.txt
writing requirements to TA_Lib.egg-info/requires.txt
writing top-level names to TA_Lib.egg-info/top_level.txt
writing manifest file 'TA_Lib.egg-info/SOURCES.txt'
reading manifest file 'TA_Lib.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'TA_Lib.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
creating build
creating build/lib.linux-x86_64-3.8
creating build/lib.linux-x86_64-3.8/talib
copying talib/test_func.py -> build/lib.linux-x86_64-3.8/talib
copying talib/stream.py -> build/lib.linux-x86_64-3.8/talib
copying talib/test_abstract.py -> build/lib.linux-x86_64-3.8/talib
copying talib/test_pandas.py -> build/lib.linux-x86_64-3.8/talib
copying talib/init.py -> build/lib.linux-x86_64-3.8/talib
copying talib/abstract.py -> build/lib.linux-x86_64-3.8/talib
copying talib/deprecated.py -> build/lib.linux-x86_64-3.8/talib
copying talib/test_stream.py -> build/lib.linux-x86_64-3.8/talib
copying talib/test_data.py -> build/lib.linux-x86_64-3.8/talib
running build_ext
building 'talib._ta_lib' extension
creating build/temp.linux-x86_64-3.8
creating build/temp.linux-x86_64-3.8/talib
x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include -I/usr/local/include -I/opt/include -I/opt/local/include -I/opt/homebrew/include -I/usr/local/lib/python3.8/dist-packages/numpy/core/include -I/usr/include/python3.8 -c talib/_ta_lib.c -o build/temp.linux-x86_64-3.8/talib/_ta_lib.o
In file included from /usr/local/lib/python3.8/dist-packages/numpy/core/include/numpy/ndarraytypes.h:1822,
from /usr/local/lib/python3.8/dist-packages/numpy/core/include/numpy/ndarrayobject.h:12,
from /usr/local/lib/python3.8/dist-packages/numpy/core/include/numpy/arrayobject.h:4,
from talib/_ta_lib.c:618:
/usr/local/lib/python3.8/dist-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
17 | #warning "Using deprecated NumPy API, disable it with "
| ^~~~~~~
talib/_ta_lib.c: In function ‘__pyx_pf_5talib_7_ta_lib_348_ta_getFuncInfo’:
talib/_ta_lib.c:38238:104: warning: passing argument 2 of ‘TA_GetFuncInfo’ from incompatible pointer type [-Wincompatible-pointer-types]
38238 | __pyx_v_retCode = TA_GetFuncInfo(__pyx_f_5talib_7_ta_lib___ta_getFuncHandle(__pyx_v_function_name), (&__pyx_v_info));
| ~^~~~~~~~~~~~~~
| |
| TA_FuncInfo ** {aka struct TA_FuncInfo **}
In file included from talib/_ta_lib.c:613:
/usr/local/include/ta-lib/ta_abstract.h:211:48: note: expected ‘const TA_FuncInfo **’ {aka ‘const struct TA_FuncInfo **’} but argument is of type ‘TA_FuncInfo **’ {aka ‘struct TA_FuncInfo **’}
211 | const TA_FuncInfo **funcInfo );
| ~~~~~~~~~~~~~~~~~~~~^~~~~~~~
talib/_ta_lib.c: In function ‘__pyx_pf_5talib_7_ta_lib_350_ta_getInputParameterInfo’:
talib/_ta_lib.c:38509:127: warning: passing argument 3 of ‘TA_GetInputParameterInfo’ from incompatible pointer type [-Wincompatible-pointer-types]
38509 | __pyx_v_retCode = TA_GetInputParameterInfo(__pyx_f_5talib_7_ta_lib___ta_getFuncHandle(__pyx_v_function_name), __pyx_v_idx, (&__pyx_v_info));
| ~^~~~~~~~~~~~~~
| |
| TA_InputParameterInfo ** {aka struct TA_InputParameterInfo **}
In file included from talib/_ta_lib.c:613:
/usr/local/include/ta-lib/ta_abstract.h:442:68: note: expected ‘const TA_InputParameterInfo **’ {aka ‘const struct TA_InputParameterInfo **’} but argument is of type ‘TA_InputParameterInfo **’ {aka ‘struct TA_InputParameterInfo **’}
442 | const TA_InputParameterInfo **info );
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
talib/_ta_lib.c: In function ‘__pyx_pf_5talib_7_ta_lib_352_ta_getOptInputParameterInfo’:
talib/_ta_lib.c:38759:130: warning: passing argument 3 of ‘TA_GetOptInputParameterInfo’ from incompatible pointer type [-Wincompatible-pointer-types]
38759 | __pyx_v_retCode = TA_GetOptInputParameterInfo(__pyx_f_5talib_7_ta_lib___ta_getFuncHandle(__pyx_v_function_name), __pyx_v_idx, (&__pyx_v_info));
| ~^~~~~~~~~~~~~~
| |
| TA_OptInputParameterInfo ** {aka struct TA_OptInputParameterInfo **}
In file included from talib/_ta_lib.c:613:
/usr/local/include/ta-lib/ta_abstract.h:446:74: note: expected ‘const TA_OptInputParameterInfo **’ {aka ‘const struct TA_OptInputParameterInfo **’} but argument is of type ‘TA_OptInputParameterInfo **’ {aka ‘struct TA_OptInputParameterInfo **’}
446 | const TA_OptInputParameterInfo **info );
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
talib/_ta_lib.c: In function ‘__pyx_pf_5talib_7_ta_lib_354_ta_getOutputParameterInfo’:
talib/_ta_lib.c:39005:128: warning: passing argument 3 of ‘TA_GetOutputParameterInfo’ from incompatible pointer type [-Wincompatible-pointer-types]
39005 | __pyx_v_retCode = TA_GetOutputParameterInfo(__pyx_f_5talib_7_ta_lib___ta_getFuncHandle(__pyx_v_function_name), __pyx_v_idx, (&__pyx_v_info));
| ~^~~~~~~~~~~~~~
| |
| TA_OutputParameterInfo ** {aka struct TA_OutputParameterInfo **}
In file included from talib/_ta_lib.c:613:
/usr/local/include/ta-lib/ta_abstract.h:450:70: note: expected ‘const TA_OutputParameterInfo **’ {aka ‘const struct TA_OutputParameterInfo **’} but argument is of type ‘TA_OutputParameterInfo **’ {aka ‘struct TA_OutputParameterInfo **’}
450 | const TA_OutputParameterInfo **info );
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
talib/_ta_lib.c: In function ‘__pyx_f_5talib_7_ta_lib___ta_getFuncHandle’:
talib/_ta_lib.c:39604:126: warning: passing argument 2 of ‘TA_GetFuncHandle’ from incompatible pointer type [-Wincompatible-pointer-types]
39604 | __pyx_t_1 = __pyx_f_5talib_7_ta_lib__ta_check_success(__pyx_n_s_TA_GetFuncHandle, TA_GetFuncHandle(__pyx_v_function_name, (&__pyx_v_handle)), 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 720, __pyx_L1_error)
| ~^~~~~~~~~~~~~~~~
| |
| TA_FuncHandle ** {aka unsigned int **}
In file included from talib/_ta_lib.c:613:
/usr/local/include/ta-lib/ta_abstract.h:155:52: note: expected ‘const TA_FuncHandle **’ {aka ‘const unsigned int **’} but argument is of type ‘TA_FuncHandle **’ {aka ‘unsigned int **’}
155 | const TA_FuncHandle **handle );
| ~~~~~~~~~~~~~~~~~~~~~~^~~~~~

@mrjbq7
Copy link
Collaborator

mrjbq7 commented Jan 15, 2021

That's odd. A couple questions:

  1. which compiler are you using?

  2. how much memory is available on the machine?

We previously had some out of memory type errors with machines with 1GB of memory.

@0zd3m1r
Copy link
Author

0zd3m1r commented Jan 15, 2021

Oops my cloud server has 1GB memory. Is that, why I can't install?

@mrjbq7
Copy link
Collaborator

mrjbq7 commented Jan 15, 2021

Possibly, yes. I'm sorry but I'm not sure what the memory requirements are, it's been reported 2GB works.

I've also heard using clang requires less memory than gcc, and also that updated gcc versions require less memory.

@0zd3m1r
Copy link
Author

0zd3m1r commented Jan 15, 2021

Thank you my friend. I will test it.

@0zd3m1r 0zd3m1r closed this as completed Jan 15, 2021
@0zd3m1r 0zd3m1r reopened this Jan 15, 2021
@nieyuda
Copy link

nieyuda commented Jan 24, 2021

Update gcc and set swap, it works!

@mrjbq7
Copy link
Collaborator

mrjbq7 commented Jan 24, 2021 via email

@ash11sh
Copy link

ash11sh commented Sep 16, 2021

Update gcc and set swap, it works!

thank you

@samgermain
Copy link
Contributor

That's odd. A couple questions:

1. which compiler are you using?

2. how much memory is available on the machine?

We previously had some out of memory type errors with machines with 1GB of memory.

How can you install with clang on Ubuntu?

I installed clang with apt-get install clang but when I try to install TA-LIB using pip install TA-LIB I receive

Building wheels for collected packages: TA-LIB
  Building wheel for TA-LIB (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /home/ubuntu/freqtrade/.env/bin/python3.9 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-vmd6wuyk/TA-LIB/setup.py'"'"'; __file__='"'"'/tmp/pip-install-vmd6wuyk/TA-LIB/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-32by1db4
       cwd: /tmp/pip-install-vmd6wuyk/TA-LIB/
  Complete output (21 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.9
  creating build/lib.linux-x86_64-3.9/talib
  copying talib/test_abstract.py -> build/lib.linux-x86_64-3.9/talib
  copying talib/test_pandas.py -> build/lib.linux-x86_64-3.9/talib
  copying talib/abstract.py -> build/lib.linux-x86_64-3.9/talib
  copying talib/test_data.py -> build/lib.linux-x86_64-3.9/talib
  copying talib/stream.py -> build/lib.linux-x86_64-3.9/talib
  copying talib/deprecated.py -> build/lib.linux-x86_64-3.9/talib
  copying talib/test_stream.py -> build/lib.linux-x86_64-3.9/talib
  copying talib/__init__.py -> build/lib.linux-x86_64-3.9/talib
  copying talib/test_func.py -> build/lib.linux-x86_64-3.9/talib
  running build_ext
  building 'talib._ta_lib' extension
  creating build/temp.linux-x86_64-3.9
  creating build/temp.linux-x86_64-3.9/talib
  x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -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/tmp/pip-install-vmd6wuyk/TA-LIB/.eggs/numpy-1.21.4-py3.9-linux-x86_64.egg/numpy/core/include -I/home/ubuntu/freqtrade/.env/include -I/usr/include/python3.9 -c talib/_ta_lib.c -o build/temp.linux-x86_64-3.9/talib/_ta_lib.o
  error: command 'x86_64-linux-gnu-gcc' failed: No such file or directory
  ----------------------------------------
  ERROR: Failed building wheel for TA-LIB
  Running setup.py clean for TA-LIB
Failed to build TA-LIB
Installing collected packages: numpy, TA-LIB
    Running setup.py install for TA-LIB ... error
    ERROR: Command errored out with exit status 1:
     command: /home/ubuntu/freqtrade/.env/bin/python3.9 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-vmd6wuyk/TA-LIB/setup.py'"'"'; __file__='"'"'/tmp/pip-install-vmd6wuyk/TA-LIB/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-cibihkga/install-record.txt --single-version-externally-managed --compile --install-headers /home/ubuntu/freqtrade/.env/include/site/python3.9/TA-LIB
         cwd: /tmp/pip-install-vmd6wuyk/TA-LIB/
    Complete output (21 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.9
    creating build/lib.linux-x86_64-3.9/talib
    copying talib/test_abstract.py -> build/lib.linux-x86_64-3.9/talib
    copying talib/test_pandas.py -> build/lib.linux-x86_64-3.9/talib
    copying talib/abstract.py -> build/lib.linux-x86_64-3.9/talib
    copying talib/test_data.py -> build/lib.linux-x86_64-3.9/talib
    copying talib/stream.py -> build/lib.linux-x86_64-3.9/talib
    copying talib/deprecated.py -> build/lib.linux-x86_64-3.9/talib
    copying talib/test_stream.py -> build/lib.linux-x86_64-3.9/talib
    copying talib/__init__.py -> build/lib.linux-x86_64-3.9/talib
    copying talib/test_func.py -> build/lib.linux-x86_64-3.9/talib
    running build_ext
    building 'talib._ta_lib' extension
    creating build/temp.linux-x86_64-3.9
    creating build/temp.linux-x86_64-3.9/talib
    x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -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/home/ubuntu/freqtrade/.env/lib/python3.9/site-packages/numpy/core/include -I/home/ubuntu/freqtrade/.env/include -I/usr/include/python3.9 -c talib/_ta_lib.c -o build/temp.linux-x86_64-3.9/talib/_ta_lib.o
    error: command 'x86_64-linux-gnu-gcc' failed: No such file or directory
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/ubuntu/freqtrade/.env/bin/python3.9 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-vmd6wuyk/TA-LIB/setup.py'"'"'; __file__='"'"'/tmp/pip-install-vmd6wuyk/TA-LIB/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-cibihkga/install-record.txt --single-version-externally-managed --compile --install-headers /home/ubuntu/freqtrade/.env/include/site/python3.9/TA-LIB Check the logs for full command output.

@samgermain
Copy link
Contributor

samgermain commented Nov 22, 2021

I noticed the error has error: command 'x86_64-linux-gnu-gcc' failed: No such file or directory but when I run clang++ -v I get

clang version 10.0.0-4ubuntu1 
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/9
Candidate multilib: .;@m64
Selected multilib: .;@m64

which looks like a suitable equivalent

@trufanov-nok
Copy link
Contributor

@samgermain

I noticed the error has error: command 'x86_64-linux-gnu-gcc' failed: No such file or directory

x86_64-linux-gnu-gcc is a part of gcc package, not clang:

$ which x86_64-linux-gnu-gcc
/usr/bin/x86_64-linux-gnu-gcc
$ dpkg -S /usr/bin/x86_64-linux-gnu-gcc
gcc: /usr/bin/x86_64-linux-gnu-gcc

How can you install with clang on Ubuntu?

Try something like that: https://stackoverflow.com/questions/51375798/setting-clang-as-default-compiler-used-in-pip-install-on-windows

@samgermain
Copy link
Contributor

@samgermain

I noticed the error has error: command 'x86_64-linux-gnu-gcc' failed: No such file or directory

x86_64-linux-gnu-gcc is a part of gcc package, not clang:

$ which x86_64-linux-gnu-gcc
/usr/bin/x86_64-linux-gnu-gcc
$ dpkg -S /usr/bin/x86_64-linux-gnu-gcc
gcc: /usr/bin/x86_64-linux-gnu-gcc

How can you install with clang on Ubuntu?

Try something like that: https://stackoverflow.com/questions/51375798/setting-clang-as-default-compiler-used-in-pip-install-on-windows

$ python setup.py build_ext --help-compiler
List of available compilers:
  --compiler=bcpp     Borland C++ Compiler
  --compiler=cygwin   Cygwin port of GNU C Compiler for Win32
  --compiler=mingw32  Mingw32 port of GNU C Compiler for Win32
  --compiler=msvc     Microsoft Visual C++
  --compiler=unix     standard UNIX-style compiler
$ which clang
/usr/bin/clang
$ pip install clang
Requirement already satisfied: clang in ./.env/lib/python3.9/site-packages (11.0)

@trufanov-nok
Copy link
Contributor

@samgermain
It seems --compiler=unix is controlled via CC environment variable:
https://github.com/python/cpython/blob/main/Lib/distutils/unixccompiler.py#L235
At least it shall understand "gcc", "g++", "clang".
So just execute CC=clang python setup.py install

@trufanov-nok
Copy link
Contributor

trufanov-nok commented Nov 22, 2021

@samgermain
Even better option is: C=clang CXX=clang LDSHARED="clang -shared" python setup.py install

Note: the LDSHARED environment parameter is overwritten to control the linker used to assemble .so library from .o object files that were build from .c sources by clang. Otherwise it'll keep using ld.
There is a list of all environment variables that distutils understand: https://github.com/python/cpython/blob/main/Lib/distutils/sysconfig.py#L219

@samgermain
Copy link
Contributor

@samgermain Even better option is: C=clang CXX=clang LDSHARED="clang -shared" python setup.py install

Note: the LDSHARED environment parameter is overwritten to control the linker used to assemble .so library from .o object files that were build from .c sources by clang. Otherwise it'll keep using ld. There is a list of all environment variables that distutils understand: https://github.com/python/cpython/blob/main/Lib/distutils/sysconfig.py#L219

I keep getting 'No module name 'numpy'', even though it looks like I have numpy installed

  File "/usr/lib/python3/dist-packages/setuptools/sandbox.py", line 45, in _execfile
    exec(code, globals, locals)
  File "/tmp/easy_install-_9xvrf3j/py_find_1st-1.1.5/setup.py", line 15, in <module>
    
ModuleNotFoundError: No module named 'numpy'
(.env) ubuntu:$ pip install numpy
Requirement already satisfied: numpy in ./.env/lib/python3.9/site-packages (1.21.4)
(.env) ubuntu:$ python3.9 -m pip install numpy
Requirement already satisfied: numpy in ./.env/lib/python3.9/site-packages (1.21.4)

I also need to specify python3.9 if I just use python I get

$ sudo CC=clang python setup.py install
sudo: python: command not found
$ sudo C=clang CXX=clang LDSHARED="clang -shared" python setup.py install
sudo: python: command not found

@trufanov-nok
Copy link
Contributor

I also need to specify python3.9 if I just use python

The python file in Linux is usually is at /usr/bin/python and it's just a symbolic link which leads to (another symbolic link etc.) a currently chosen python version.

$ which python
/usr/bin/python
$ ls -n /usr/bin/python
lrwxrwxrwx 1 0 0 24 jul 25 14:42 /usr/bin/python -> /etc/alternatives/python
$ ls -n /etc/alternatives/python
lrwxrwxrwx 1 0 0 16 jul 25 14:45 /etc/alternatives/python -> /usr/bin/python3
$ ls -n /usr/bin/python3
lrwxrwxrwx 2 0 0 9 oct  7 13:23 /usr/bin/python3 -> python3.9
$ ls -n /usr/bin/python3.9
-rwxr-xr-x 1 0 0 5426648 sep 10 17:59 /usr/bin/python3.9

One can change the python version it links to with sudo update-alternatives --config python
Or manually:

sudo rm /usr/bin/python
sudo ln -n    /usr/bin/python3    /usr/bin/python

Or perhaps you may better reinstall python to let it fix its environment:
sudo apt install --reinstall python3 python-is-python3

I keep getting 'No module name 'numpy''

When exactly this is happening? Launch python, type import numpy. Will it work? Or its happening during ta-lib's compilation?
Also I'm not python expert but it seems that site-packages is the target directory of manually built Python packages. Mine is installed at /usr/lib/python3/dist-packages/numpy/. You may better to delete this package from ./.env/lib/python3.9/site-packages and install it via pip again. Or sudo apt install python3-numpy

@samgermain
Copy link
Contributor

I also need to specify python3.9 if I just use python

The python file in Linux is usually is at /usr/bin/python and it's just a symbolic link which leads to (another symbolic link etc.) a currently chosen python version.

$ which python
/usr/bin/python
$ ls -n /usr/bin/python
lrwxrwxrwx 1 0 0 24 jul 25 14:42 /usr/bin/python -> /etc/alternatives/python
$ ls -n /etc/alternatives/python
lrwxrwxrwx 1 0 0 16 jul 25 14:45 /etc/alternatives/python -> /usr/bin/python3
$ ls -n /usr/bin/python3
lrwxrwxrwx 2 0 0 9 oct  7 13:23 /usr/bin/python3 -> python3.9
$ ls -n /usr/bin/python3.9
-rwxr-xr-x 1 0 0 5426648 sep 10 17:59 /usr/bin/python3.9

One can change the python version it links to with sudo update-alternatives --config python Or manually:

sudo rm /usr/bin/python
sudo ln -n    /usr/bin/python3    /usr/bin/python

Or perhaps you may better reinstall python to let it fix its environment: sudo apt install --reinstall python3 python-is-python3

I keep getting 'No module name 'numpy''

When exactly this is happening? Launch python, type import numpy. Will it work? Or its happening during ta-lib's compilation? Also I'm not python expert but it seems that site-packages is the target directory of manually built Python packages. Mine is installed at /usr/lib/python3/dist-packages/numpy/. You may better to delete this package from ./.env/lib/python3.9/site-packages and install it via pip again. Or sudo apt install python3-numpy

I'm back to square 1
https://stackoverflow.com/questions/70062856/install-ta-lib-with-clang-compiler-error-command-x86-64-linux-gnu-gcc-failed

@trufanov-nok
Copy link
Contributor

Your code snippet contains two successive compilation related commands and their output after execution. The first command is:

clang -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -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/home/ubuntu/.local/lib/python3.9/site-packages/numpy/core/include -I/usr/include/python3.9 -c talib/_ta_lib.c -o build/temp.linux-x86_64-3.9/talib/_ta_lib.o

E.g. clang -some_params -I include_dirs -c _ta_lib.c -o _ta_lib.o
It's a compilation (creation of an object .o files from project sources .c). And it succeed with 6 warnings.
The second one is:

x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fwrapv -O2 -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.9/talib/_ta_lib.o -L/usr/local/lib -L/usr/local/lib64 -L/opt/lib -L/opt/local/lib -L/opt/homebrew/lib -L/opt/homebrew/opt/ta-lib/lib -Wl,--enable-new-dtags,-R/usr/local/lib -Wl,--enable-new-dtags,-R/usr/local/lib64 -Wl,--enable-new-dtags,-R/opt/lib -Wl,--enable-new-dtags,-R/opt/local/lib -Wl,--enable-new-dtags,-R/opt/homebrew/lib -Wl,--enable-new-dtags,-R/opt/homebrew/opt/ta-lib/lib -lta_lib -o build/lib.linux-x86_64-3.9/talib/_ta_lib.cpython-39-x86_64-linux-gnu.so

E.g. x86_64-linux-gnu-gcc -shared -some_params _ta_lib.o -lta_lib -o _ta_lib.cpython-39-x86_64-linux-gnu.so
That's a linking process - it's trying to assemble all compiled object files into the shared library .so and link it with existing C library (ta_lib.so) while resolving all function calls references in them. And it fails.

So the compilation step is using clang and only the final linking is using x86_64-linux-gnu-gcc.

Have you tried sudo CC=clang LDSHARED="clang -shared" python3.9 -m pip install TA-LIB ?

@samgermain
Copy link
Contributor

sudo CC=clang LDSHARED="clang -shared" python3.9 -m pip install TA-LIB

That worked, I took out the sudo though cause you shouldn't use sudo pip. What is LDSHARED="clang -shared"?

@mrjbq7
Copy link
Collaborator

mrjbq7 commented Jan 22, 2022 via email

@samgermain
Copy link
Contributor

If you’d like to contribute a not to README for instructions building with clang that would be nice

On Fri, Jan 21, 2022 at 6:27 PM Sam Germain @.> wrote: sudo CC=clang LDSHARED="clang -shared" python3.9 -m pip install TA-LIB That worked, I took out the sudo though cause you shouldn't use sudo pip. What is LDSHARED="clang -shared"? — Reply to this email directly, view it on GitHub <#386 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAF5A3QHHBIC3XGDNQLDXDUXIIXTANCNFSM4WDZT3KA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you commented.Message ID: @.>

a not?

@mrjbq7
Copy link
Collaborator

mrjbq7 commented Jan 22, 2022 via email

@trufanov-nok
Copy link
Contributor

sudo CC=clang LDSHARED="clang -shared" python3.9 -m pip install TA-LIB

That worked, I took out the sudo though cause you shouldn't use sudo pip. What is LDSHARED="clang -shared"?

That's the env variable which usage I found in distutils module code which is used by setup.py
https://github.com/python/cpython/blob/main/Lib/distutils/sysconfig.py#L219
I don't remember details. I'm not a python developer and this was in November.

@BourneSuper
Copy link

0.5G memory, 2G swap not works
1G memory, 2G swap works

@mrjbq7
Copy link
Collaborator

mrjbq7 commented Apr 16, 2022

Closing all installation issues, if someone has a specific problem please open a new one.

@mrjbq7 mrjbq7 closed this as completed Apr 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants