kr-colab / diploSHIC

feature-based deep learning for the identification of selective sweeps
MIT License
50 stars 14 forks source link

Compatible with python 2.7? #2

Closed oushujun closed 6 years ago

oushujun commented 6 years ago

Hello,

I was trying to compile diploSHIC and received similar warnings for the numpy (ref #1), but I was using the numpy-1.11.2-py2.7-linux-x86_64 version.

sudo python setup.py install running install running build running config_cc unifing config_cc, config, build_clib, build_ext, build commands --compiler options running config_fc unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options running build_src build_src building extension "shicstats" sources creating build creating build/src.linux-x86_64-2.7 f2py options: [] f2py: ./shicstats.pyf Reading fortran codes... Reading file './shicstats.pyf' (format:free) Line #6 in ./shicstats.pyf:" intent(c)" All arguments will have attribute intent(c) Line #14 in ./shicstats.pyf:" intent(c)" All arguments will have attribute intent(c) Line #21 in ./shicstats.pyf:" intent(c)" All arguments will have attribute intent(c) Line #28 in ./shicstats.pyf:" intent(c)" All arguments will have attribute intent(c) Line #36 in ./shicstats.pyf:" intent(c)" All arguments will have attribute intent(c) Line #44 in ./shicstats.pyf:" intent(c)" All arguments will have attribute intent(c) crackline: groupcounter=1 groupname={0: '', 1: 'python module', 2: 'interface', 3: 'subroutine'} crackline: Mismatch of blocks encountered. Trying to fix it by assuming "end" statement. Post-processing... Block: shicstats Block: computeR2Matrix Block: omega Block: ZnS Block: pairwiseDiffs Block: pairwiseDiffsDiplo Block: getHaplotypeFreqSpec Post-processing (stage 2)... Building modules... Building module "shicstats"... Constructing wrapper function "computeR2Matrix"... r2Matrix = computeR2Matrix(haps) Constructing wrapper function "omega"... omegaMax = omega(r2Matrix) Constructing wrapper function "ZnS"... zns = ZnS(r2Matrix) Constructing wrapper function "pairwiseDiffs"... diffLs = pairwiseDiffs(haps) Constructing wrapper function "pairwiseDiffsDiplo"... diffLs = pairwiseDiffsDiplo(haps) Constructing wrapper function "getHaplotypeFreqSpec"... hapCounts = getHaplotypeFreqSpec(haps) Wrote C/API module "shicstats" to file "build/src.linux-x86_64-2.7/shicstatsmodule.c" adding 'build/src.linux-x86_64-2.7/fortranobject.c' to sources. adding 'build/src.linux-x86_64-2.7' to include_dirs. copying /usr/lib64/python2.7/site-packages/numpy/f2py/src/fortranobject.c -> build/src.linux-x86_64-2.7 copying /usr/lib64/python2.7/site-packages/numpy/f2py/src/fortranobject.h -> build/src.linux-x86_64-2.7 build_src: building npy-pkg config files running build_ext customize UnixCCompiler customize UnixCCompiler using build_ext building 'shicstats' extension compiling C sources C compiler: gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC

creating build/temp.linux-x86_64-2.7 creating build/temp.linux-x86_64-2.7/build creating build/temp.linux-x86_64-2.7/build/src.linux-x86_64-2.7 compile options: '-Ibuild/src.linux-x86_64-2.7 -I/usr/lib64/python2.7/site-packages/numpy/core/include -I/usr/include/python2.7 -c' gcc: build/src.linux-x86_64-2.7/shicstatsmodule.c In file included from /usr/lib64/python2.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1728:0, from /usr/lib64/python2.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:17, from /usr/lib64/python2.7/site-packages/numpy/core/include/numpy/arrayobject.h:15, from build/src.linux-x86_64-2.7/fortranobject.h:13, from build/src.linux-x86_64-2.7/shicstatsmodule.c:18: /usr/lib64/python2.7/site-packages/numpy/core/include/numpy/npy_deprecated_api.h:11:2: warning: #warning "Using deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]

warning "Using deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION"

^ build/src.linux-x86_64-2.7/shicstatsmodule.c:104:12: warning: ‘f2py_size’ defined but not used [-Wunused-function] static int f2py_size(PyArrayObject* var, ...) ^ gcc: build/src.linux-x86_64-2.7/fortranobject.c In file included from /usr/lib64/python2.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1728:0, from /usr/lib64/python2.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:17, from /usr/lib64/python2.7/site-packages/numpy/core/include/numpy/arrayobject.h:15, from build/src.linux-x86_64-2.7/fortranobject.h:13, from build/src.linux-x86_64-2.7/fortranobject.c:2: /usr/lib64/python2.7/site-packages/numpy/core/include/numpy/npy_deprecated_api.h:11:2: warning: #warning "Using deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]

warning "Using deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION"

^ gcc: ./utils.c creating build/lib.linux-x86_64-2.7 gcc -pthread -shared -Wl,-z,relro build/temp.linux-x86_64-2.7/build/src.linux-x86_64-2.7/shicstatsmodule.o build/temp.linux-x86_64-2.7/utils.o build/temp.linux-x86_64-2.7/build/src.linux-x86_64-2.7/fortranobject.o -L. -lpython2.7 -o build/lib.linux-x86_64-2.7/shicstats.so running scons running install_lib copying build/lib.linux-x86_64-2.7/shicstats.so -> /usr/lib64/python2.7/site-packages running install_egg_info Removing /usr/lib64/python2.7/site-packages/UNKNOWN-0.0.0-py2.7.egg-info Writing /usr/lib64/python2.7/site-packages/UNKNOWN-0.0.0-py2.7.egg-info running install_clib customize UnixCCompiler

However, I could not pass the test:

python diploSHIC.py train training/ testing/ fooModel --epochs 10 Traceback (most recent call last): File "diploSHIC.py", line 115, in import matplotlib File "/opt/software/matplotlib/1.5.3--GCC-4.8.5/lib64/python2.7/site-packages/matplotlib-1.5.3-py2.7-linux-x86_64.egg/matplotlib/init.py", line 122, in from matplotlib.cbook import is_string_like, mplDeprecation, dedent, get_label File "/opt/software/matplotlib/1.5.3--GCC-4.8.5/lib64/python2.7/site-packages/matplotlib-1.5.3-py2.7-linux-x86_64.egg/matplotlib/cbook.py", line 33, in import numpy as np File "/opt/software/NumPy/1.11.2--GCC-4.8.5/lib64/python2.7/site-packages/numpy-1.11.2-py2.7-linux-x86_64.egg/numpy/init.py", line 142, in from . import add_newdocs File "/opt/software/NumPy/1.11.2--GCC-4.8.5/lib64/python2.7/site-packages/numpy-1.11.2-py2.7-linux-x86_64.egg/numpy/add_newdocs.py", line 13, in from numpy.lib import add_newdoc File "/opt/software/NumPy/1.11.2--GCC-4.8.5/lib64/python2.7/site-packages/numpy-1.11.2-py2.7-linux-x86_64.egg/numpy/lib/init.py", line 8, in from .type_check import * File "/opt/software/NumPy/1.11.2--GCC-4.8.5/lib64/python2.7/site-packages/numpy-1.11.2-py2.7-linux-x86_64.egg/numpy/lib/type_check.py", line 11, in import numpy.core.numeric as _nx File "/opt/software/NumPy/1.11.2--GCC-4.8.5/lib64/python2.7/site-packages/numpy-1.11.2-py2.7-linux-x86_64.egg/numpy/core/init.py", line 14, in from . import multiarray ImportError: dynamic module does not define module export function (PyInit_multiarray)

I wonder if this is due to the use of python 2.7?

Thanks! Shujun

oushujun commented 6 years ago

Hello,

I tried different versions of python and numpy and found that the error was due to limited write permission. Because pip install tensorflow and keras require root privilege, so after installation, packages modifying these contents will also need root privilege. So what I did was:

$ sudo pip install tensorflow $ sudo pip install keras $ git clone https://github.com/kern-lab/diploSHIC.git $ cd diploSHIC $ which python ~/bin/anaconda3/bin/python $ sudo ~/bin/anaconda3/bin/python setup.py install $ sudo ~/bin/anaconda3/bin/python diploSHIC.py train training/ testing/ fooModel --epochs 10 $ sudo ~/bin/anaconda3/bin/python diploSHIC.py predict fooModel.json fooModel.weights.hdf5 testEmpirical.fvec testEmpirical.preds

I have't not tested on my real data, so not sure if sudo privilige is necessary for my actual analyses.

I'll close this thread and hopfully it would be useful to others.

Shujun