Biopython build errors on Mageia - linux

I'm trying to install Biopython 1.61. I'm logged in as root in a bash terminal. I'm using Mageia 2.0, and I've updated all the packages/programs on the OS (with urpmi update -a).
I extracted the source, then ran python setup.py build, which had two errors:
FAIL: test_protein_16130152 (test_SeqIO_online.EntrezTests)
Bio.Entrez.efetch(protein, 16130152, ...)
----------------------------------------------------------------------
Traceback (most recent call last):
File "test_SeqIO_online.py", line 77, in <lambda>
method = lambda x : x.simple(d, f, e, l, c)
File "test_SeqIO_online.py", line 65, in simple
self.assertEqual(seguid(record.seq), checksum)
AssertionError: 'NT/aFiTXyD/7KixizZ9sq2FcniU' != 'fCjcjMFeGIrilHAn6h+yju267lg'
======================================================================
ERROR: test_doctests (test_Tutorial.TutorialTestCase)
Run tutorial doctests.
----------------------------------------------------------------------
Traceback (most recent call last):
File "test_Tutorial.py", line 152, in test_doctests
ValueError: 4 Tutorial doctests failed: test_from_line_05671, test_from_line_06030, test_from_line_06190, test_from_line_06479
Then I ran python setup.py install, but it failed, too. I updated my python with (urpmi install lib64python-devel) and my gcc, but it was already up to date.
This is the error I get from python setup.py install:
[root#localhost biopython-1.61]# python setup.py install
running install
running build
running build_py
warning: build_py_biopython: byte-compiling is disabled, skipping.
running build_ext
building 'Bio.Cluster.cluster' extension
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -I/usr/include/ncursesw -DNDEBUG -O2 -g -pipe -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -g -fPIC -I/usr/lib64/python2.7/site-packages/numpy/core/include -I/usr/include/python2.7 -c Bio/Cluster/clustermodule.c -o build/temp.linux-x86_64-2.7/Bio/Cluster/clustermodule.o
Bio/Cluster/clustermodule.c:2:31: fatal error: numpy/arrayobject.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1

The unit test failures have been fixed in Biopython itself.
The compiler error suggests you are missing the NumPy header files, often included in the OS package manager in a separate package called something like numpy-dev or numpy-devel.

Related

Encountered a problem while installing [ FastText ] library on MacOS

I have been trying to install the "FastText" library on macOS but I keep encountering a Runtime error.
System - MacOS: 13.0.1 (22A400)
Python Version: 3.10
IDE: Pycharm
I tried installing it from Pycharm but it did not work, then i tried using the Terminal and this is what i got.
pip3 install fasttext and sudo pip3 install fasttext
all resulted with the same error below:
Using cached fasttext-0.9.2.tar.gz (68 kB)
Preparing metadata (setup.py) ... done
Requirement already satisfied: pybind11>=2.2 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from fasttext) (2.10.2)
Requirement already satisfied: setuptools>=0.7.0 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from fasttext) (65.5.0)
Requirement already satisfied: numpy in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from fasttext) (1.21.4)
Building wheels for collected packages: fasttext
Building wheel for fasttext (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [67 lines of output]
/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/dist.py:771: UserWarning: Usage of dash-separated 'description-file' will not be supported in future versions. Please use the underscore name 'description_file' instead
warnings.warn(
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-10.9-universal2-cpython-310
creating build/lib.macosx-10.9-universal2-cpython-310/fasttext
copying python/fasttext_module/fasttext/__init__.py -> build/lib.macosx-10.9-universal2-cpython-310/fasttext
copying python/fasttext_module/fasttext/FastText.py -> build/lib.macosx-10.9-universal2-cpython-310/fasttext
creating build/lib.macosx-10.9-universal2-cpython-310/fasttext/util
copying python/fasttext_module/fasttext/util/util.py -> build/lib.macosx-10.9-universal2-cpython-310/fasttext/util
copying python/fasttext_module/fasttext/util/__init__.py -> build/lib.macosx-10.9-universal2-cpython-310/fasttext/util
creating build/lib.macosx-10.9-universal2-cpython-310/fasttext/tests
copying python/fasttext_module/fasttext/tests/test_script.py -> build/lib.macosx-10.9-universal2-cpython-310/fasttext/tests
copying python/fasttext_module/fasttext/tests/__init__.py -> build/lib.macosx-10.9-universal2-cpython-310/fasttext/tests
copying python/fasttext_module/fasttext/tests/test_configurations.py -> build/lib.macosx-10.9-universal2-cpython-310/fasttext/tests
running build_ext
creating var
creating var/folders
creating var/folders/xg
creating var/folders/xg/jxm9dqwn5k3f4m0ns9rwyldw0000gn
creating var/folders/xg/jxm9dqwn5k3f4m0ns9rwyldw0000gn/T
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch arm64 -arch x86_64 -g -I/Library/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c /var/folders/xg/jxm9dqwn5k3f4m0ns9rwyldw0000gn/T/tmpejxme0zs.cpp -o var/folders/xg/jxm9dqwn5k3f4m0ns9rwyldw0000gn/T/tmpejxme0zs.o -stdlib=libc++
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch arm64 -arch x86_64 -g -I/Library/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c /var/folders/xg/jxm9dqwn5k3f4m0ns9rwyldw0000gn/T/tmpyu7_bprq.cpp -o var/folders/xg/jxm9dqwn5k3f4m0ns9rwyldw0000gn/T/tmpyu7_bprq.o -stdlib=libc++ -mmacosx-version-min=10.7
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "/private/var/folders/xg/jxm9dqwn5k3f4m0ns9rwyldw0000gn/T/pip-install-mv_4oqbh/fasttext_1af9a5c892f74b668dc43e515183597f/setup.py", line 168, in <module>
setup(
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/__init__.py", line 87, in setup
return distutils.core.setup(**attrs)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 185, in setup
return run_commands(dist)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
dist.run_commands()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 968, in run_commands
self.run_command(cmd)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/dist.py", line 1217, in run_command
super().run_command(command)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 987, in run_command
cmd_obj.run()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/wheel/bdist_wheel.py", line 299, in run
self.run_command('build')
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 319, in run_command
self.distribution.run_command(command)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/dist.py", line 1217, in run_command
super().run_command(command)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 987, in run_command
cmd_obj.run()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/_distutils/command/build.py", line 132, in run
self.run_command(cmd_name)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 319, in run_command
self.distribution.run_command(command)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/dist.py", line 1217, in run_command
super().run_command(command)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 987, in run_command
cmd_obj.run()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/command/build_ext.py", line 84, in run
_build_ext.run(self)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 346, in run
self.build_extensions()
File "/private/var/folders/xg/jxm9dqwn5k3f4m0ns9rwyldw0000gn/T/pip-install-mv_4oqbh/fasttext_1af9a5c892f74b668dc43e515183597f/setup.py", line 131, in build_extensions
raise RuntimeError(
RuntimeError: libc++ is needed! Failed to compile with -stdlib=libc++ -mmacosx-version-min=10.7 and -stdlib=libc++.
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for fasttext
Running setup.py clean for fasttext
Failed to build fasttext
Installing collected packages: fasttext
Running setup.py install for fasttext ... error
error: subprocess-exited-with-error
× Running setup.py install for fasttext did not run successfully.
│ exit code: 1
╰─> [66 lines of output]
/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/dist.py:771: UserWarning: Usage of dash-separated 'description-file' will not be supported in future versions. Please use the underscore name 'description_file' instead
warnings.warn(
running install
/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
running build
running build_py
creating build
creating build/lib.macosx-10.9-universal2-cpython-310
creating build/lib.macosx-10.9-universal2-cpython-310/fasttext
copying python/fasttext_module/fasttext/__init__.py -> build/lib.macosx-10.9-universal2-cpython-310/fasttext
copying python/fasttext_module/fasttext/FastText.py -> build/lib.macosx-10.9-universal2-cpython-310/fasttext
creating build/lib.macosx-10.9-universal2-cpython-310/fasttext/util
copying python/fasttext_module/fasttext/util/util.py -> build/lib.macosx-10.9-universal2-cpython-310/fasttext/util
copying python/fasttext_module/fasttext/util/__init__.py -> build/lib.macosx-10.9-universal2-cpython-310/fasttext/util
creating build/lib.macosx-10.9-universal2-cpython-310/fasttext/tests
copying python/fasttext_module/fasttext/tests/test_script.py -> build/lib.macosx-10.9-universal2-cpython-310/fasttext/tests
copying python/fasttext_module/fasttext/tests/__init__.py -> build/lib.macosx-10.9-universal2-cpython-310/fasttext/tests
copying python/fasttext_module/fasttext/tests/test_configurations.py -> build/lib.macosx-10.9-universal2-cpython-310/fasttext/tests
running build_ext
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch arm64 -arch x86_64 -g -I/Library/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c /var/folders/xg/jxm9dqwn5k3f4m0ns9rwyldw0000gn/T/tmp7pgbysh_.cpp -o var/folders/xg/jxm9dqwn5k3f4m0ns9rwyldw0000gn/T/tmp7pgbysh_.o -stdlib=libc++
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch arm64 -arch x86_64 -g -I/Library/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c /var/folders/xg/jxm9dqwn5k3f4m0ns9rwyldw0000gn/T/tmp7hnnqnja.cpp -o var/folders/xg/jxm9dqwn5k3f4m0ns9rwyldw0000gn/T/tmp7hnnqnja.o -stdlib=libc++ -mmacosx-version-min=10.7
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "/private/var/folders/xg/jxm9dqwn5k3f4m0ns9rwyldw0000gn/T/pip-install-mv_4oqbh/fasttext_1af9a5c892f74b668dc43e515183597f/setup.py", line 168, in <module>
setup(
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/__init__.py", line 87, in setup
return distutils.core.setup(**attrs)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 185, in setup
return run_commands(dist)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
dist.run_commands()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 968, in run_commands
self.run_command(cmd)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/dist.py", line 1217, in run_command
super().run_command(command)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 987, in run_command
cmd_obj.run()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/command/install.py", line 68, in run
return orig.install.run(self)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/_distutils/command/install.py", line 698, in run
self.run_command('build')
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 319, in run_command
self.distribution.run_command(command)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/dist.py", line 1217, in run_command
super().run_command(command)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 987, in run_command
cmd_obj.run()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/_distutils/command/build.py", line 132, in run
self.run_command(cmd_name)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 319, in run_command
self.distribution.run_command(command)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/dist.py", line 1217, in run_command
super().run_command(command)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 987, in run_command
cmd_obj.run()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/command/build_ext.py", line 84, in run
_build_ext.run(self)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 346, in run
self.build_extensions()
File "/private/var/folders/xg/jxm9dqwn5k3f4m0ns9rwyldw0000gn/T/pip-install-mv_4oqbh/fasttext_1af9a5c892f74b668dc43e515183597f/setup.py", line 131, in build_extensions
raise RuntimeError(
RuntimeError: libc++ is needed! Failed to compile with -stdlib=libc++ -mmacosx-version-min=10.7 and -stdlib=libc++.
[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.
╰─> fasttext
note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure. ```
As an initial observation: it's often a good practice to install the Python libraries you need for a particular development project into a project-specific virtual environment.
That is, you set up a separate and specific Python interpreter, of a version you consciously choose, with its own set of installed libraries, which does not then affect the system's default Python installation in any way. It then becomes easier to choose whatever libraries/versions you need for that project, without any risk of confusing things for other programs on the same system. It also helps enforce a clear declaration of your project's actual prerequisites, so that you can re-create an adequante virtual-environment later when needed in new places – rather than leaving that to the chance/history of what's been globally installed on the devlopment machine.
Either the conda tool or the venv functionality of Python 3 can be used to set up such an environment, and after creation, each time you want to use that specific Python installation, you must activate it – so that in a particular shell, it becomes the active Python.
All that said, the error you're having relates to the lack of needed c++ development tools, which your installation-method seems to require to compile to those non-Python parts of Facebook's FastText library.
A bunch of options you could consider to get around this:
installing Apple's full XCode, including C++ & a bunch of other compilation/build tools, might resolve or change your error. There's more discussion from people who've hit a similar error, and eventually gotten around it using XCode-related configuration, at an issue in the Fasttext project: https://github.com/facebookresearch/fastText/issues/753
if using conda – I usually start with miniconda per the minimal instructions at https://docs.conda.io/en/latest/miniconda.html – it might be smart enough to choose a package already precompiled properly for your setup, even if you don't have C++ build tools locally. That is, after setting up your desired environment, then activating it, doing a conda install fasttext inside that environment might just work for you, skipping the local compilation error.
depending on your fasttext needs, you might also consider using some other Python library with FastText support, like Gensim. It doesn't support -supervised mode, but does support the core word-vectors (and synthesis of out-of-vocabulary word-vectors via character n-grams) capabilities of FastText, with some extra flexibility & related utility functions.

Attempt to compile Scipy on Android Termux Python 3.10

I am deeply frustrated by rolling-releases of Termux with no regard to previous python releases and modules
Now I am compiling latest got version of Scipy but before that I am running
export BLAS=/data/data/com.termux/files/usr/lib/libblas.so
export LAPACK=/data/data/com.termux/files/usr/lib/liblapack.so
export CC=clang
export CPP=clang++
python runtests.py -v
https://scipy.github.io/devdocs/dev/contributor/runtests.html
There were some missing packages which I installed via pip
Following is the output & I need help here
Building, see build.log...
... build in progress (0:01:00.279236 elapsed)
Running from SciPy source directory.
scipy/linalg/_generate_pyx.py: all files up-to-date
scipy/special/_generate_pyx.py: all files up-to-date
Running scipy/linalg/_generate_pyx.py
Running scipy/special/_generate_pyx.py
Running scipy/stats/_generate_pyx.py
scipy/_lib/_ccallback_c.pyx has not changed
scipy/_lib/_test_deprecation_call.pyx has not changed
scipy/_lib/messagestream.pyx has not changed
scipy/cluster/_hierarchy.pyx has not changed
scipy/_lib/_test_deprecation_def.pyx has not changed
scipy/cluster/_vq.pyx has not changed
scipy/fftpack/convolve.pyx has not changed
scipy/interpolate/_bspl.pyx has not changed
scipy/cluster/_optimal_leaf_ordering.pyx has not changed
scipy/interpolate/_ppoly.pyx has not changed
scipy/interpolate/interpnd.pyx has not changed
scipy/io/matlab/_mio5_utils.pyx has not changed
scipy/io/matlab/_mio_utils.pyx has not changed
scipy/io/matlab/_streams.pyx has not changed
scipy/linalg/_cythonized_array_utils.pyx has not changed
scipy/linalg/_decomp_update.pyx.in has not changed
scipy/linalg/_matfuncs_expm.pyx.in has not changed
scipy/linalg/_matfuncs_sqrtm_triu.pyx has not changed
scipy/linalg/cython_blas.pyx has not changed
scipy/linalg/_solve_toeplitz.pyx has not changed
scipy/linalg/cython_lapack.pyx has not changed
scipy/ndimage/src/_cytest.pyx has not changed
scipy/ndimage/src/_ni_label.pyx has not changed
scipy/optimize/_bglu_dense.pyx has not changed
scipy/optimize/_group_columns.pyx has not changed
scipy/optimize/_highs/cython/src/_highs_constants.pyx has not changed
scipy/optimize/_highs/cython/src/_highs_wrapper.pyx has not changed
scipy/optimize/_lsq/givens_elimination.pyx has not changed
scipy/optimize/_trlib/_trlib.pyx has not changed
scipy/optimize/cython_optimize/_zeros.pyx.in has not changed
scipy/optimize/tnc/_moduleTNC.pyx has not changed
scipy/signal/_max_len_seq_inner.pyx has not changed
scipy/signal/_peak_finding_utils.pyx has not changed
scipy/signal/_sosfilt.pyx has not changed
scipy/signal/_spectral.pyx has not changed
scipy/signal/_upfirdn_apply.pyx has not changed
scipy/sparse/_csparsetools.pyx.in has not changed
scipy/sparse/csgraph/_flow.pyx has not changed
scipy/sparse/csgraph/_matching.pyx has not changed
scipy/sparse/csgraph/_min_spanning_tree.pyx has not changed
scipy/sparse/csgraph/_reordering.pyx has not changed
scipy/sparse/csgraph/_shortest_path.pyx has not changed
scipy/sparse/csgraph/_tools.pyx has not changed
scipy/sparse/csgraph/_traversal.pyx has not changed
scipy/spatial/_ckdtree.pyx has not changed
scipy/spatial/_hausdorff.pyx has not changed
scipy/spatial/_qhull.pyx has not changed
scipy/spatial/_voronoi.pyx has not changed
scipy/spatial/transform/_rotation.pyx has not changed
scipy/special/_comb.pyx has not changed
scipy/special/_ellip_harm_2.pyx has not changed
scipy/special/_test_round.pyx has not changed
scipy/special/_ufuncs.pyx has not changed
scipy/special/_ufuncs_cxx.pyx has not changed
scipy/special/cython_special.pyx has not changed
scipy/stats/_qmc_cy.pyx has not changed
scipy/stats/_sobol.pyx has not changed
scipy/stats/_biasedurn.pyx has not changed
scipy/stats/_stats.pyx has not changed
scipy/stats/_boost/src/beta_ufunc.pyx has not changed
scipy/stats/_boost/src/nbinom_ufunc.pyx has not changed
scipy/stats/_boost/src/binom_ufunc.pyx has not changed
scipy/stats/_boost/src/hypergeom_ufunc.pyx has not changed
scipy/stats/_boost/src/ncf_ufunc.pyx has not changed
scipy/stats/_levy_stable/levyst.pyx has not changed
scipy/stats/_unuran/unuran_wrapper.pyx has not changed
/data/data/com.termux/files/usr/lib/python3.10/site-packages/setuptools/config/pyprojecttoml.py:102: _ExperimentalProjectMetadata: Support for project metadata in `pyproject.toml` is still experimental and may be removed (or change) in future releases.
warnings.warn(msg, _ExperimentalProjectMetadata)
Cythonizing sources
INFO: lapack_opt_info:
INFO: lapack_armpl_info:
INFO: customize UnixCCompiler
INFO: libraries armpl_lp64_mp not found in ['/data/data/com.termux/files/usr/lib']
INFO: NOT AVAILABLE
INFO:
INFO: lapack_mkl_info:
INFO: libraries mkl_rt not found in ['/data/data/com.termux/files/usr/lib']
INFO: NOT AVAILABLE
INFO:
INFO: openblas_lapack_info:
INFO: C compiler: clang -mfloat-abi=softfp -mfpu=vfpv3-d16 -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -march=armv7-a -mfpu=neon -mfloat-abi=softfp -mthumb -fstack-protector-strong -O3 -march=armv7-a -mfpu=neon -mfloat-abi=softfp -mthumb -fstack-protector-strong -O3 -fPIC
creating /data/data/com.termux/files/usr/tmp/tmpw9i7rrqz/data
creating /data/data/com.termux/files/usr/tmp/tmpw9i7rrqz/data/data
creating /data/data/com.termux/files/usr/tmp/tmpw9i7rrqz/data/data/com.termux
creating /data/data/com.termux/files/usr/tmp/tmpw9i7rrqz/data/data/com.termux/files
creating /data/data/com.termux/files/usr/tmp/tmpw9i7rrqz/data/data/com.termux/files/usr
creating /data/data/com.termux/files/usr/tmp/tmpw9i7rrqz/data/data/com.termux/files/usr/tmp
creating /data/data/com.termux/files/usr/tmp/tmpw9i7rrqz/data/data/com.termux/files/usr/tmp/tmpw9i7rrqz
INFO: compile options: '-c'
INFO: clang: /data/data/com.termux/files/usr/tmp/tmpw9i7rrqz/source.c
INFO: clang /data/data/com.termux/files/usr/tmp/tmpw9i7rrqz/data/data/com.termux/files/usr/tmp/tmpw9i7rrqz/source.o -L/data/data/com.termux/files/usr/lib -lopenblas -o /data/data/com.termux/files/usr/tmp/tmpw9i7rrqz/a.out
INFO: FOUND:
INFO: libraries = ['openblas', 'openblas']
INFO: library_dirs = ['/data/data/com.termux/files/usr/lib']
INFO: language = c
INFO: define_macros = [('HAVE_CBLAS', None)]
INFO:
INFO: FOUND:
INFO: libraries = ['openblas', 'openblas']
INFO: library_dirs = ['/data/data/com.termux/files/usr/lib']
INFO: language = c
INFO: define_macros = [('HAVE_CBLAS', None)]
INFO:
non-existing path in 'scipy/linalg': 'src/lapack_deprecations/LICENSE'
INFO: blas_opt_info:
INFO: blas_armpl_info:
INFO: libraries armpl_lp64_mp not found in ['/data/data/com.termux/files/usr/lib']
INFO: NOT AVAILABLE
INFO:
INFO: blas_mkl_info:
INFO: libraries mkl_rt not found in ['/data/data/com.termux/files/usr/lib']
INFO: NOT AVAILABLE
INFO:
INFO: blis_info:
INFO: libraries blis not found in ['/data/data/com.termux/files/usr/lib']
INFO: NOT AVAILABLE
INFO:
INFO: openblas_info:
INFO: C compiler: clang -mfloat-abi=softfp -mfpu=vfpv3-d16 -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -march=armv7-a -mfpu=neon -mfloat-abi=softfp -mthumb -fstack-protector-strong -O3 -march=armv7-a -mfpu=neon -mfloat-abi=softfp -mthumb -fstack-protector-strong -O3 -fPIC
creating /data/data/com.termux/files/usr/tmp/tmp0139l74e/data
creating /data/data/com.termux/files/usr/tmp/tmp0139l74e/data/data
creating /data/data/com.termux/files/usr/tmp/tmp0139l74e/data/data/com.termux
creating /data/data/com.termux/files/usr/tmp/tmp0139l74e/data/data/com.termux/files
creating /data/data/com.termux/files/usr/tmp/tmp0139l74e/data/data/com.termux/files/usr
creating /data/data/com.termux/files/usr/tmp/tmp0139l74e/data/data/com.termux/files/usr/tmp
creating /data/data/com.termux/files/usr/tmp/tmp0139l74e/data/data/com.termux/files/usr/tmp/tmp0139l74e
INFO: compile options: '-c'
INFO: clang: /data/data/com.termux/files/usr/tmp/tmp0139l74e/source.c
INFO: clang /data/data/com.termux/files/usr/tmp/tmp0139l74e/data/data/com.termux/files/usr/tmp/tmp0139l74e/source.o -L/data/data/com.termux/files/usr/lib -lopenblas -o /data/data/com.termux/files/usr/tmp/tmp0139l74e/a.out
INFO: FOUND:
INFO: libraries = ['openblas', 'openblas']
INFO: library_dirs = ['/data/data/com.termux/files/usr/lib']
INFO: language = c
INFO: define_macros = [('HAVE_CBLAS', None)]
INFO:
INFO: FOUND:
INFO: libraries = ['openblas', 'openblas']
INFO: library_dirs = ['/data/data/com.termux/files/usr/lib']
INFO: language = c
INFO: define_macros = [('HAVE_CBLAS', None)]
INFO:
Traceback (most recent call last):
File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/scipy/setup.py", line 532, in <module>
setup_package()
File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/scipy/setup.py", line 528, in setup_package
setup(**metadata)
File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/numpy/distutils/core.py", line 135, in setup
config = configuration()
File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/scipy/setup.py", line 438, in configuration
config.add_subpackage('scipy')
File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/numpy/distutils/misc_util.py", line 1054, in add_subpackage
config_list = self.get_subpackage(subpackage_name, subpackage_path,
File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/numpy/distutils/misc_util.py", line 1020, in get_subpackage
config = self._get_configuration_from_setup_py(
File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/numpy/distutils/misc_util.py", line 962, in _get_configuration_from_setup_py
config = setup_module.configuration(*args)
File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/scipy/scipy/setup.py", line 18, in configuration
config.add_subpackage('optimize')
File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/numpy/distutils/misc_util.py", line 1054, in add_subpackage
config_list = self.get_subpackage(subpackage_name, subpackage_path,
File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/numpy/distutils/misc_util.py", line 1020, in get_subpackage
config = self._get_configuration_from_setup_py(
File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/numpy/distutils/misc_util.py", line 962, in _get_configuration_from_setup_py
config = setup_module.configuration(*args)
File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/scipy/scipy/optimize/setup.py", line 130, in configuration
config.add_subpackage('_highs')
File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/numpy/distutils/misc_util.py", line 1054, in add_subpackage
config_list = self.get_subpackage(subpackage_name, subpackage_path,
File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/numpy/distutils/misc_util.py", line 1020, in get_subpackage
config = self._get_configuration_from_setup_py(
File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/numpy/distutils/misc_util.py", line 962, in _get_configuration_from_setup_py
config = setup_module.configuration(*args)
File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/scipy/scipy/optimize/_highs/setup.py", line 63, in configuration
_major_dot_minor = _get_version(
File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/scipy/scipy/optimize/_highs/setup.py", line 50, in _get_version
with open(CMakeLists, 'r', encoding='utf-8') as f:
FileNotFoundError: [Errno 2] No such file or directory: '/data/data/com.termux/files/usr/lib/python3.10/site-packages/scipy/scipy/_lib/highs/CMakeLists.txt'
Build failed! (0:01:17.306152 elapsed)
Clean Install Termux on Samsung Z Flip 4
https://www.youtube.com/watch?v=yDwxmF0Kn-Q
update
upgrade
apt install python (3.11.1 was installed)
To manage and access files in termux then you must type the below command
termux-setup-storage
pkg install tur-repo
pkg install python-scipy
connected phone via usb to a computer and copied my python scripts to phone downloads folder
cp ~/storage/downloads/file.py ~/ to run programs from termux home.
You get Deprecation Warnings for interp2d which will be replaced in scipy
so add to stop them at the top.
import warnings
warnings.filterwarnings("ignore", category=DeprecationWarning)
The end. ps
All woks fine and tested on 2d interpolation arrays.
I assume that what you want is the latest version of Scipy working in Termux.
I think you are making it difficult for yourself.
I managed to compile and install scipy 1.8.1 correctly for python 3.10.4 using only Termux.
First, get rid of all exports before installation. As a side note, if no CC env. variable is set, pip will use aarch64-linux-android-clang by default.
You don't need libblas.so and liblapack.so either.
It is indeed necessary to have the BLAS/LAPACK libraries when compiling Scipy, but you can simply get them by pkg in openblas.
Once done, a simple pip install scipy worked like a charm for me (it took me more than 15 minutes to build it, so be patient).
Hope it helps you ^^
Although I was unable to install Scipy via pip for Python 3.11, which is the current version used in Termux as of today, I managed to build Scipy 1.9.0 and install it manually.
Apart from some dependencies I installed via pkg, which were requested by the build system, such as pytest, I had to try with different versions of pip-installed libraries. The required libraries and versions that worked were:
beniget==0.4.1
Cython==0.29.32
distro==1.8.0
gast==0.5.3
meson==0.62.2
meson-python==0.7.0
mpmath==1.2.1
ninja==1.11.1
numpy==1.23.5
packaging==21.3
pip==22.3.1
ply==3.11
pybind11==2.9.2
pyparsing==3.0.9
pyproject-metadata==0.6.1
pythran==0.11.0
scikit-build==0.16.2
setuptools==65.6.3
tomli==2.0.1
wheel==0.37.1
I'm not sure if all of them are required. With them installed, I obtained the sources tarball for scipy-1.9.0, uncompressed it, and executed runtests.py (found in the root of the uncompressed tree).
After this, a working build of scipy was created in "build/lib.linux-aarch64-cpython-311/scipy", I copied it to the system package directory: "/data/data/com.termux/files/home/../usr/lib/python3.11/site-packages/", and now I can use scipy again.

python llvmlite installtion iisue - SVML not detected

Trying to make a python script having numba 0.33.0 as dependency work on ubuntu 14.0.4. Have installed llvm 6.0 for the same and set the llvm_config variable to llvm_config location.
Facing issues while building llvmlite
Following is the stack trace
Installing collected packages: llvmlite, numba
Running setup.py install for llvmlite ... error
Complete output from command /home/ubuntu/www/Spam_detection_algo/spam/bin/python3 -u -c "import setuptools, tokenize;file='/tmp/pip-install-lca77547/llvmlite/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-a53bsnug/install-record.txt --single-version-externally-managed --compile --install-headers /home/ubuntu/www/Spam_detection_algo/spam/include/site/python3.4/llvmlite:
running install
running build
got version from file /tmp/pip-install-lca77547/llvmlite/llvmlite/_version.py {'full': '02bd87a8449bb2984e9791bdd1d653338442b6b8', 'version': '0.23.2'}
▽
running build_ext
/home/ubuntu/www/Spam_detection_algo/spam/bin/python3 /tmp/pip-install-lca77547/llvmlite/ffi/build.py
LLVM version... # static-libstdc++ avoids runtime dependencies on a
# particular libstdc++ version.
g++ -shared -I/usr/lib/llvm-6.0/include -std=c++0x -fuse-ld=gold -Wl,--no-keep-files-mapped -Wl,--no-map-whole-files -fPIC -fvisibility-inlines-hidden -Werror=date-time -std=c++11 -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment -ffunction-sections -fdata-sections -O2 -DNDEBUG -fno-exceptions -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -fno-rtti -g -flto assembly.cpp bitcode.cpp core.cpp initfini.cpp module.cpp value.cpp executionengine.cpp transforms.cpp passmanagers.cpp targets.cpp dylib.cpp linker.cpp object_file.cpp -o libllvmlite.so -L/usr/lib/llvm-6.0/lib -flto -Wl,--exclude-libs=ALL -lLLVM-6.0
cc1plus: error: -Werror=date-time: no option -Wdate-time
cc1plus: error: -Werror=date-time: no option -Wdate-time
cc1plus: error: -Werror=date-time: no option -Wdate-time
cc1plus: error: -Werror=date-time: no option -Wdate-time
cc1plus: error: -Werror=date-time: no option -Wdate-time
cc1plus: error: -Werror=date-time: no option -Wdate-time
cc1plus: error: -Werror=date-time: no option -Wdate-time
cc1plus: error: -Werror=date-time: no option -Wdate-time
cc1plus: error: -Werror=date-time: no option -Wdate-time
cc1plus: error: -Werror=date-time: no option -Wdate-time
cc1plus: error: -Werror=date-time: no option -Wdate-time
cc1plus: error: -Werror=date-time: no option -Wdate-time
cc1plus: error: -Werror=date-time: no option -Wdate-time
make: *** [libllvmlite.so] Error 1
6.0.1
SVML not detected
Traceback (most recent call last):
File "/tmp/pip-install-lca77547/llvmlite/ffi/build.py", line 153, in <module>
main()
File "/tmp/pip-install-lca77547/llvmlite/ffi/build.py", line 143, in main
main_posix('linux', '.so')
File "/tmp/pip-install-lca77547/llvmlite/ffi/build.py", line 135, in main_posix
subprocess.check_call(['make', '-f', makefile])
File "/usr/lib/python3.4/subprocess.py", line 561, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['make', '-f', 'Makefile.linux']' returned non-zero exit status 2
error: command '/home/ubuntu/www/Spam_detection_algo/spam/bin/python3' failed with exit status 1
Please check your LLVM_CONFIG environment variable as noted here.
If your LLVM is installed in a nonstandard location, set the
LLVM_CONFIG environment variable to the location of the corresponding
llvm-config or llvm-config.exe executable. This variable must persist
into the installation of llvmlite—for example, into a Python
environment.
EXAMPLE: If LLVM is installed in /opt/llvm/ with the llvm-config
binary located at /opt/llvm/bin/llvm-config, set
LLVM_CONFIG=/opt/llvm/bin/llvm-config.

In the centos6.5 system deployment gym environment error

I installed and deployed the gym on the centos6.5 system. The following is the installation process.
Install anaconda
Wget --no-check-certificate https://repo.anaconda.com/archive/Anaconda3-5.1.0-Linux-x86_64.sh
Create a virtual environment
Conda create --name gymlab python=3.6
Install gym
Source activate gym
Git clone https://github.com/openai/gym.git
Cd gym
Pip install '.[all]'
Run "pip install '.[all]' "The last step, reported the following error:
Processing /root/gym
Requirement already satisfied: numpy>=1.10.4 in /root/anaconda3/envs/gymlab/lib/python3.6/site-packages (from gym==0.10.5) (1.14.3)
Requirement already satisfied: requests>=2.0 in /root/anaconda3/envs/gymlab/lib/python3.6/site-packages (from gym==0.10.5) (2.18.4)
Requirement already satisfied: six in /root/anaconda3/envs/gymlab/lib/python3.6/site-packages (from gym==0.10.5) (1.11.0)
Requirement already satisfied: pyglet>=1.2.0 in /root/anaconda3/envs/gymlab/lib/python3.6/site-packages (from gym==0.10.5) (1.3.2)
Requirement already satisfied: atari_py>=0.1.1 in /root/anaconda3/envs/gymlab/lib/python3.6/site-packages (from gym==0.10.5) (0.1.1)
Requirement already satisfied: Pillow in /root/anaconda3/envs/gymlab/lib/python3.6/site-packages (from gym==0.10.5) (5.1.0)
Requirement already satisfied: PyOpenGL in /root/anaconda3/envs/gymlab/lib/python3.6/site-packages (from gym==0.10.5) (3.1.0)
Collecting Box2D-kengz (from gym==0.10.5)
Using cached https://files.pythonhosted.org/packages/81/20/51d6c0c87f7642efb709c518fb0ca8e5eab068259588552c41da5926ae27/Box2D-kengz-2.3.3.tar.gz
Collecting mujoco_py>=1.50 (from gym==0.10.5)
Collecting imageio (from gym==0.10.5)
Using cached https://files.pythonhosted.org/packages/a7/1d/33c8686072148b3b0fcc12a2e0857dd8316b8ae20a0fa66c8d6a6d01c05c/imageio-2.3.0-py2.py3-none-any.whl
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /root/anaconda3/envs/gymlab/lib/python3.6/site-packages (from requests>=2.0->gym==0.10.5) (3.0.4)
Requirement already satisfied: certifi>=2017.4.17 in /root/anaconda3/envs/gymlab/lib/python3.6/site-packages (from requests>=2.0->gym==0.10.5) (2018.4.16)
Requirement already satisfied: idna<2.7,>=2.5 in /root/anaconda3/envs/gymlab/lib/python3.6/site-packages (from requests>=2.0->gym==0.10.5) (2.6)
Requirement already satisfied: urllib3<1.23,>=1.21.1 in /root/anaconda3/envs/gymlab/lib/python3.6/site-packages (from requests>=2.0->gym==0.10.5) (1.22)
Requirement already satisfied: future in /root/anaconda3/envs/gymlab/lib/python3.6/site-packages (from pyglet>=1.2.0->gym==0.10.5) (0.16.0)
Collecting glfw>=1.4.0 (from mujoco_py>=1.50->gym==0.10.5)
Collecting cffi>=1.10 (from mujoco_py>=1.50->gym==0.10.5)
Using cached https://files.pythonhosted.org/packages/6d/c0/47db8f624f3e4e2f3f27be03a93379d1ba16a1450a7b1aacfa0366e2c0dd/cffi-1.11.5-cp36-cp36m-manylinux1_x86_64.whl
Collecting Cython>=0.27.2 (from mujoco_py>=1.50->gym==0.10.5)
Using cached https://files.pythonhosted.org/packages/19/eb/c4d9f3beafd5ac0615936860bcee41d93ca58f8734a16715da0037d2c468/Cython-0.28.2-cp36-cp36m-manylinux1_x86_64.whl
Collecting pycparser (from cffi>=1.10->mujoco_py>=1.50->gym==0.10.5)
Building wheels for collected packages: gym, Box2D-kengz
Running setup.py bdist_wheel for gym ... done
Stored in directory: /tmp/pip-ephem-wheel-cache-or4iim1z/wheels/6e/18/10/1234738b0aafab3f8f70d61d2763dc3efda78a41d153584dee
Running setup.py bdist_wheel for Box2D-kengz ... error
Complete output from command /root/anaconda3/envs/gymlab/bin/python -u -c "import setuptools, tokenize;file='/tmp/pip-install-5jh8n6q7/Box2D-kengz/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-ckydr3cn --python-tag cp36:
Using setuptools (version 39.1.0).
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/Box2D
copying library/Box2D/Box2D.py -> build/lib.linux-x86_64-3.6/Box2D
copying library/Box2D/init.py -> build/lib.linux-x86_64-3.6/Box2D
creating build/lib.linux-x86_64-3.6/Box2D/b2
copying library/Box2D/b2/init.py -> build/lib.linux-x86_64-3.6/Box2D/b2
running build_ext
building 'Box2D._Box2D' extension
swigging Box2D/Box2D.i to Box2D/Box2D_wrap.cpp
swig -python -c++ -IBox2D -small -O -includeall -ignoremissing -w201 -globals b2Globals -outdir library/Box2D -keyword -w511 -D_SWIG_KWARGS -o Box2D/Box2D_wrap.cpp Box2D/Box2D.i
Box2D/Common/b2Math.h:66: Warning(302): Identifier 'b2Vec2' redefined by %extend (ignored),
Box2D/Box2D_math.i:47: Warning(302): %extend definition of 'b2Vec2'.
Box2D/Common/b2Math.h:157: Warning(302): Identifier 'b2Vec3' redefined by %extend (ignored),
Box2D/Box2D_math.i:168: Warning(302): %extend definition of 'b2Vec3'.
Box2D/Common/b2Math.h:196: Warning(302): Identifier 'b2Mat22' redefined by %extend (ignored),
Box2D/Box2D_math.i:301: Warning(302): %extend definition of 'b2Mat22'.
Box2D/Common/b2Math.h:270: Warning(302): Identifier 'b2Mat33' redefined by %extend (ignored),
Box2D/Box2D_math.i:372: Warning(302): %extend definition of 'b2Mat33'.
Box2D/Collision/b2DynamicTree.h:43: Warning(312): Nested union not currently supported (ignored).
Box2D/Common/b2Settings.h:144: Warning(506): Can't wrap varargs with keyword arguments enabled
Box2D/Common/b2Math.h:90: Warning(509): Overloaded method b2Vec2::operator ()(int32) is shadowed by b2Vec2::operator ()(int32) const at Box2D/Common/b2Math.h:84.
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/Box2D
creating build/temp.linux-x86_64-3.6/Box2D/Dynamics
creating build/temp.linux-x86_64-3.6/Box2D/Dynamics/Contacts
creating build/temp.linux-x86_64-3.6/Box2D/Dynamics/Joints
creating build/temp.linux-x86_64-3.6/Box2D/Common
creating build/temp.linux-x86_64-3.6/Box2D/Collision
creating build/temp.linux-x86_64-3.6/Box2D/Collision/Shapes
gcc -pthread -B /root/anaconda3/envs/gymlab/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/root/anaconda3/envs/gymlab/include/python3.6m -c Box2D/Box2D_wrap.cpp -o build/temp.linux-x86_64-3.6/Box2D/Box2D_wrap.o -I. -Wno-unused
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
Box2D/Box2D_wrap.cpp: In function ‘swig_module_info* SWIG_Python_GetModule()’:
Box2D/Box2D_wrap.cpp:2453:51: error: ‘PyCObject_Import’ was not declared in this scope
(char*)"type_pointer" SWIG_TYPE_TABLE_NAME);
^
Box2D/Box2D_wrap.cpp: In function ‘void SWIG_Python_SetModule(swig_module_info*)’:
Box2D/Box2D_wrap.cpp:2522:92: error: ‘PyCObject_FromVoidPtr’ was not declared in this scope
PyObject *pointer = PyCObject_FromVoidPtr((void ) swig_module, SWIG_Python_DestroyModule);
^
Box2D/Box2D_wrap.cpp: In function ‘swig_type_info SWIG_Python_TypeQuery(const char*)’:
Box2D/Box2D_wrap.cpp:2545:60: error: ‘PyCObject_AsVoidPtr’ was not declared in this scope
descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj);
^
Box2D/Box2D_wrap.cpp:2550:51: error: ‘PyCObject_FromVoidPtr’ was not declared in this scope
obj = PyCObject_FromVoidPtr(descriptor, NULL);
^
error: command 'gcc' failed with exit status 1
----------------------------------------
Failed building wheel for Box2D-kengz
Running setup.py clean for Box2D-kengz
Successfully built gym
Failed to build Box2D-kengz
Installing collected packages: Box2D-kengz, glfw, imageio, pycparser, cffi, Cython, mujoco-py, gym
Running setup.py install for Box2D-kengz ... error
Complete output from command /root/anaconda3/envs/gymlab/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-5jh8n6q7/Box2D-kengz/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-cwa7ey1x/install-record.txt --single-version-externally-managed --compile:
Using setuptools (version 39.1.0).
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/Box2D
copying library/Box2D/Box2D.py -> build/lib.linux-x86_64-3.6/Box2D
copying library/Box2D/__init__.py -> build/lib.linux-x86_64-3.6/Box2D
creating build/lib.linux-x86_64-3.6/Box2D/b2
copying library/Box2D/b2/__init__.py -> build/lib.linux-x86_64-3.6/Box2D/b2
running build_ext
building 'Box2D._Box2D' extension
swigging Box2D/Box2D.i to Box2D/Box2D_wrap.cpp
swig -python -c++ -IBox2D -small -O -includeall -ignoremissing -w201 -globals b2Globals -outdir library/Box2D -keyword -w511 -D_SWIG_KWARGS -o Box2D/Box2D_wrap.cpp Box2D/Box2D.i
Box2D/Common/b2Math.h:66: Warning(302): Identifier 'b2Vec2' redefined by %extend (ignored),
Box2D/Box2D_math.i:47: Warning(302): %extend definition of 'b2Vec2'.
Box2D/Common/b2Math.h:157: Warning(302): Identifier 'b2Vec3' redefined by %extend (ignored),
Box2D/Box2D_math.i:168: Warning(302): %extend definition of 'b2Vec3'.
Box2D/Common/b2Math.h:196: Warning(302): Identifier 'b2Mat22' redefined by %extend (ignored),
Box2D/Box2D_math.i:301: Warning(302): %extend definition of 'b2Mat22'.
Box2D/Common/b2Math.h:270: Warning(302): Identifier 'b2Mat33' redefined by %extend (ignored),
Box2D/Box2D_math.i:372: Warning(302): %extend definition of 'b2Mat33'.
Box2D/Collision/b2DynamicTree.h:43: Warning(312): Nested union not currently supported (ignored).
Box2D/Common/b2Settings.h:144: Warning(506): Can't wrap varargs with keyword arguments enabled
Box2D/Common/b2Math.h:90: Warning(509): Overloaded method b2Vec2::operator ()(int32) is shadowed by b2Vec2::operator ()(int32) const at Box2D/Common/b2Math.h:84.
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/Box2D
creating build/temp.linux-x86_64-3.6/Box2D/Dynamics
creating build/temp.linux-x86_64-3.6/Box2D/Dynamics/Contacts
creating build/temp.linux-x86_64-3.6/Box2D/Dynamics/Joints
creating build/temp.linux-x86_64-3.6/Box2D/Common
creating build/temp.linux-x86_64-3.6/Box2D/Collision
creating build/temp.linux-x86_64-3.6/Box2D/Collision/Shapes
gcc -pthread -B /root/anaconda3/envs/gymlab/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/root/anaconda3/envs/gymlab/include/python3.6m -c Box2D/Box2D_wrap.cpp -o build/temp.linux-x86_64-3.6/Box2D/Box2D_wrap.o -I. -Wno-unused
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
Box2D/Box2D_wrap.cpp: In function ‘swig_module_info* SWIG_Python_GetModule()’:
Box2D/Box2D_wrap.cpp:2453:51: error: ‘PyCObject_Import’ was not declared in this scope
(char*)"type_pointer" SWIG_TYPE_TABLE_NAME);
^
Box2D/Box2D_wrap.cpp: In function ‘void SWIG_Python_SetModule(swig_module_info*)’:
Box2D/Box2D_wrap.cpp:2522:92: error: ‘PyCObject_FromVoidPtr’ was not declared in this scope
PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule);
^
Box2D/Box2D_wrap.cpp: In function ‘swig_type_info* SWIG_Python_TypeQuery(const char*)’:
Box2D/Box2D_wrap.cpp:2545:60: error: ‘PyCObject_AsVoidPtr’ was not declared in this scope
descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj);
^
Box2D/Box2D_wrap.cpp:2550:51: error: ‘PyCObject_FromVoidPtr’ was not declared in this scope
obj = PyCObject_FromVoidPtr(descriptor, NULL);
^
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "/root/anaconda3/envs/gymlab/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-5jh8n6q7/Box2D-kengz/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-cwa7ey1x/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-5jh8n6q7/Box2D-kengz/
((swig issues :))
Box2D/Box2D_wrap.cpp: In function ‘swig_module_info* SWIG_Python_GetModule()’:
Box2D/Box2D_wrap.cpp:2453:51: error: ‘PyCObject_Import’ was not declared in this scope
CentOS 6.9, a "build gym example". (Note: No Box2D, gym issues when using an other OS with swig3 installed by default.)
Build swig-3
cd swig-3.0.12/
./configure --with-php --without-go --prefix=/usr/
make
# make install
gym-0.10.5 :
git clone https://github.com/openai/gym.git
cd gym/
# scl enable rh-python36 bash
# pip3.6 install '.[all]'
.
.
Running setup.py install for Box2D-kengz ... done
Running setup.py install for glfw ... done
Running setup.py install for pycparser ... done
Running setup.py install for mujoco-py ... done
Running setup.py install for gym ... done
Successfully installed Box2D-kengz-2.3.3 Cython-0.28.2 cffi-1.11.5 glfw-1.6.0 gym-0.10.5 imageio-2.3.0 mujoco-py-1.50.1.56 pycparser-2.18
According to the above error message I downloaded the latest version of Box2D to install, but reported the following error:
[root#localhost Box2D-kengz-2.3.3]# python setup.py install
Using setuptools (version 39.1.0).
running install
running bdist_egg
running egg_info
writing library/Box2D_kengz.egg-info/PKG-INFO
writing dependency_links to library/Box2D_kengz.egg-info/dependency_links.txt
writing top-level names to library/Box2D_kengz.egg-info/top_level.txt
reading manifest file 'library/Box2D_kengz.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'INSTALL'
warning: no files found matching 'MANIFEST'
warning: no files found matching 'README'
warning: no files found matching 'distribute_setup.py'
warning: no files found matching '.py' under directory 'Box2D'
warning: no files found matching '.c' under directory 'Box2D'
writing manifest file 'library/Box2D_kengz.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
copying library/Box2D/Box2D.py -> build/lib.linux-x86_64-3.6/Box2D
copying library/Box2D/init.py -> build/lib.linux-x86_64-3.6/Box2D
running build_ext
building 'Box2D._Box2D' extension
swigging Box2D/Box2D.i to Box2D/Box2D_wrap.cpp
swig -python -c++ -IBox2D -small -O -includeall -ignoremissing -w201 -globals b2Globals -outdir library/Box2D -keyword -w511 -D_SWIG_KWARGS -o Box2D/Box2D_wrap.cpp Box2D/Box2D.i
Box2D/Common/b2Math.h:66: Warning(302): Identifier 'b2Vec2' redefined by %extend (ignored),
Box2D/Box2D_math.i:47: Warning(302): %extend definition of 'b2Vec2'.
Box2D/Common/b2Math.h:157: Warning(302): Identifier 'b2Vec3' redefined by %extend (ignored),
Box2D/Box2D_math.i:168: Warning(302): %extend definition of 'b2Vec3'.
Box2D/Common/b2Math.h:196: Warning(302): Identifier 'b2Mat22' redefined by %extend (ignored),
Box2D/Box2D_math.i:301: Warning(302): %extend definition of 'b2Mat22'.
Box2D/Common/b2Math.h:270: Warning(302): Identifier 'b2Mat33' redefined by %extend (ignored),
Box2D/Box2D_math.i:372: Warning(302): %extend definition of 'b2Mat33'.
Box2D/Collision/b2DynamicTree.h:43: Warning(312): Nested union not currently supported (ignored).
Box2D/Common/b2Settings.h:144: Warning(506): Can't wrap varargs with keyword arguments enabled
Box2D/Common/b2Math.h:90: Warning(509): Overloaded method b2Vec2::operator ()(int32) is shadowed by b2Vec2::operator ()(int32) const at Box2D/Common/b2Math.h:84.
gcc -pthread -B /root/anaconda3/envs/gymlab/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/root/anaconda3/envs/gymlab/include/python3.6m -c Box2D/Box2D_wrap.cpp -o build/temp.linux-x86_64-3.6/Box2D/Box2D_wrap.o -I. -Wno-unused
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
Box2D/Box2D_wrap.cpp: In function ‘swig_module_info* SWIG_Python_GetModule()’:
Box2D/Box2D_wrap.cpp:2453:51: error: ‘PyCObject_Import’ was not declared in this scope
(char*)"type_pointer" SWIG_TYPE_TABLE_NAME);
^
Box2D/Box2D_wrap.cpp: In function ‘void SWIG_Python_SetModule(swig_module_info*)’:
Box2D/Box2D_wrap.cpp:2522:92: error: ‘PyCObject_FromVoidPtr’ was not declared in this scope
PyObject *pointer = PyCObject_FromVoidPtr((void ) swig_module, SWIG_Python_DestroyModule);
^
Box2D/Box2D_wrap.cpp: In function ‘swig_type_info SWIG_Python_TypeQuery(const char*)’:
Box2D/Box2D_wrap.cpp:2545:60: error: ‘PyCObject_AsVoidPtr’ was not declared in this scope
descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj);
^
Box2D/Box2D_wrap.cpp:2550:51: error: ‘PyCObject_FromVoidPtr’ was not declared in this scope
obj = PyCObject_FromVoidPtr(descriptor, NULL);
^
error: command 'gcc' failed with exit status 1

SWIG Symbol not found, leading underscore in symbol name

I'm following the tutorial for SWIG and Python, but I'm getting an error when I try to import the compiled extension in Python.
Python 3.5.2 (default, Oct 11 2016, 15:01:25)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.38)] on darwin
>>> import _example
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dlopen(/pat/to/_example.cpython-35m-darwin.so, 2): Symbol not found: _fact
Referenced from: /path/to/_example.cpython-35m-darwin.so
Expected in: flat namespace
in /path/to/_example.cpython-35m-darwin.so
Note that the error says it can't find the symbol _fact. I'm not sure where the leading underscore is coming from, and I can't find any information about how to resolve this problem.
Here is example.i (matches what's in the tutorial):
%module example
%{
#define SWIG_FILE_WITH_INIT
#include "example.h"
%}
int fact(int n);
example.h and example.c also match what's in the tutorial; I can post here if necessary.
Here's setup.py:
# coding=utf-8
from setuptools import Extension, setup
setup(
name = 'SWIG Test',
ext_modules = [Extension('_example', ['example.i'])],
py_modules = ['example'],
)
This is the relevant output of pip install -e . -v:
running build_ext
building '_example' extension
swigging example.i to example_wrap.c
swig -python -o example_wrap.c example.i
creating build
creating build/temp.macosx-10.12-x86_64-3.5
/usr/bin/clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -pipe -Os -I/opt/local/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5m -c example_wrap.c -o build/temp.macosx-10.12-x86_64-3.5/example_wrap.o
creating build/lib.macosx-10.12-x86_64-3.5
/usr/bin/clang -bundle -undefined dynamic_lookup -L/opt/local/lib -Wl,-headerpad_max_install_names build/temp.macosx-10.12-x86_64-3.5/example_wrap.o -o build/lib.macosx-10.12-x86_64-3.5/_example.cpython-35m-darwin.so
copying build/lib.macosx-10.12-x86_64-3.5/_example.cpython-35m-darwin.so ->
Some things that I've tried that didn't work:
Declaring fact as int fact(int n) asm("fact") (after building, I get Symbol not found: fact when importing).
Adding swig_opts=['-py3'] to the extension in setup.py.
The leading underscore was a red herring. Turns out, I simply forgot to include example.c in my extension sources.
Here's what setup.py is supposed to look like:
# coding=utf-8
from setuptools import Extension, setup
setup(
name = 'SWIG Test',
ext_modules = [Extension('_example', ['example.i', 'example.c'])],
py_modules = ['example'],
)
Note that the extension has both example.i and example.c in its sources.
Now everything works as expected (:
Python 3.5.2 (default, Oct 11 2016, 15:01:25)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.38)] on darwin
>>> import example
>>> example.fact(42)
0
>>> example.fact(0)
1

Resources