rkern / line_profiler

(OLD REPO) Line-by-line profiling for Python - Current repo ->
https://github.com/pyutils/line_profiler
Other
3.6k stars 254 forks source link

error: command 'clang' failed with exit status 1 on pip install python 3.5 in virtualenv #87

Closed cyclehacker closed 5 years ago

cyclehacker commented 7 years ago

When I try and install line_profiler the install fails with the above error. This is the full output from the install: `Collecting line_profiler Using cached line_profiler-2.0.tar.gz Requirement already satisfied: IPython>=0.13 in ./scraper_test/lib/python3.5/site-packages (from line_profiler) Requirement already satisfied: simplegeneric>0.8 in ./scraper_test/lib/python3.5/site-packages (from IPython>=0.13->line_profiler) Requirement already satisfied: pickleshare in ./scraper_test/lib/python3.5/site-packages (from IPython>=0.13->line_profiler) Requirement already satisfied: prompt-toolkit<2.0.0,>=1.0.4 in ./scraper_test/lib/python3.5/site-packages (from IPython>=0.13->line_profiler) Requirement already satisfied: traitlets>=4.2 in ./scraper_test/lib/python3.5/site-packages (from IPython>=0.13->line_profiler) Requirement already satisfied: pexpect; sys_platform != "win32" in ./scraper_test/lib/python3.5/site-packages (from IPython>=0.13->line_profiler) Requirement already satisfied: decorator in ./scraper_test/lib/python3.5/site-packages (from IPython>=0.13->line_profiler) Requirement already satisfied: setuptools>=18.5 in ./scraper_test/lib/python3.5/site-packages (from IPython>=0.13->line_profiler) Requirement already satisfied: pygments in ./scraper_test/lib/python3.5/site-packages (from IPython>=0.13->line_profiler) Requirement already satisfied: wcwidth in ./scraper_test/lib/python3.5/site-packages (from prompt-toolkit<2.0.0,>=1.0.4->IPython>=0.13->line_profiler) Requirement already satisfied: six>=1.9.0 in ./scraper_test/lib/python3.5/site-packages (from prompt-toolkit<2.0.0,>=1.0.4->IPython>=0.13->line_profiler) Requirement already satisfied: ipython-genutils in ./scraper_test/lib/python3.5/site-packages (from traitlets>=4.2->IPython>=0.13->line_profiler) Requirement already satisfied: ptyprocess>=0.5 in ./scraper_test/lib/python3.5/site-packages (from pexpect; sys_platform != "win32"->IPython>=0.13->line_profiler) Installing collected packages: line-profiler Running setup.py install for line-profiler ... error Complete output from command /home/me/py_environments/scraper_test/bin/python3.5 -u -c "import setuptools, tokenize;file='/tmp/pip-build-rwjm2xr2/line-profiler/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-lx_5rnzu-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/me/py_environments/scraper_test/include/site/python3.5/line-profiler: running install running build running build_py creating build creating build/lib.linux-x86_64-3.5 copying line_profiler.py -> build/lib.linux-x86_64-3.5 copying kernprof.py -> build/lib.linux-x86_64-3.5 running build_ext skipping '_line_profiler.c' Cython extension (up-to-date) building '_line_profiler' extension creating build/temp.linux-x86_64-3.5 clang -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -ggdb3 -O0 -std=c99 -Wall -Werror -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/home/me/py_environments/scraper_test/include -I/usr/include/python3.5m -c _line_profiler.c -o build/temp.linux-x86_64-3.5/_line_profiler.o _line_profiler.c:7597:28: error: unused function 'Pyx_PyObject_AsString' [-Werror,-Wunused-function] static CYTHON_INLINE char __Pyx_PyObject_AsString(PyObject o) { ^ _line_profiler.c:7594:32: error: unused function '__Pyx_PyUnicode_FromString' [-Werror,-Wunused-function] static CYTHON_INLINE PyObject* Pyx_PyUnicode_FromString(const char c_str) { ^ _line_profiler.c:7659:26: error: unused function '__Pyx_PyObject_IsTrue' [-Werror,-Wunused-function] static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject x) { ^ _line_profiler.c:7709:33: error: unused function 'Pyx_PyIndex_AsSsize_t' [-Werror,-Wunused-function] static CYTHON_INLINE Py_ssize_t Pyx_PyIndex_AsSsize_t(PyObject b) { ^ _line_profiler.c:7771:33: error: unused function '__Pyx_PyInt_FromSize_t' [-Werror,-Wunused-function] static CYTHON_INLINE PyObject Pyx_PyInt_FromSize_t(size_t ival) { ^ _line_profiler.c:6636:28: error: unused function 'Pyx_CyFunction_InitDefaults' [-Werror,-Wunused-function] static CYTHON_INLINE void __Pyx_CyFunction_InitDefaults(PyObject func, size_t size, int pyobjects) { ^ _line_profiler.c:6645:27: error: unused function 'Pyx_CyFunction_SetDefaultsTuple' [-Werror,-Wunused-function] static CYTHON_INLINE void Pyx_CyFunction_SetDefaultsTuple(PyObject func, PyObject tuple) { ^ _line_profiler.c:6650:27: error: unused function 'Pyx_CyFunction_SetDefaultsKwDict' [-Werror,-Wunused-function] static CYTHON_INLINE void Pyx_CyFunction_SetDefaultsKwDict(PyObject func, PyObject dict) { ^ _line_profiler.c:6655:27: error: unused function '__Pyx_CyFunction_SetAnnotationsDict' [-Werror,-Wunused-function] static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject func, PyObject dict) { ^ 9 errors generated. error: command 'clang' failed with exit status 1

----------------------------------------

Command "/home/me/py_environments/scraper_test/bin/python3.5 -u -c "import setuptools, tokenize;file='/tmp/pip-build-rwjm2xr2/line-profiler/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-lx_5rnzu-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/me/py_environments/scraper_test/include/site/python3.5/line-profiler" failed with error code 1 in /tmp/pip-build-rwjm2xr2/line-profiler/`

Any assistance you can provide would be much appreciated.

johnyf commented 7 years ago

These "unused function" errors seem to be due to the -Werror option passed to clang when the Cython extension is compiled. -Werror turns warnings into errors. Searching for Werror in the line_profiler repository, it doesn't originate from there (setup.py does not pass any flags to the compiler, as far as I can tell).

These may be default options that were used when compiling Python (based on this comment).

A temporary solution could be to pass different flags when creating the Extension using extra_compile_args (example). This discussion may be relevant too.

Trying to compile with gcc would be another thing to try, but that will probably require first compiling Python using gcc.

cyclehacker commented 7 years ago

Thanks for the fast response, I'll look into the possible solutions you have offered. Best, Fraser

johnyf commented 7 years ago

Coincidentally encountered this potentially relevant discussion about removing selected arguments when building Cython extensions.

cyclehacker commented 7 years ago

Yeah, I had a similar error when trying to install pycares except it was 'error: implicit declaration of function 'clock_gettime' is invalid in C99 ' which I managed to resolve by adding a the '--std=gnu99' flag to extra_compile_args in setup.py. I managed to analyse the memory usage using tracemalloc so didn't finish trying to install line profiler. But will likely give it another go when I next need it.