I am currently working with an API named cocoapi that used Cython to compile .c file on Ubuntu 16.04 LTS. I can use the API flawlessly with IPython on terminal, but when run the python file on Spyder I got this error:
ImportError: Building module pycocotools._mask failed: ["CompileError: command 'gcc' failed with exit status 1\n"]
I use Anaconda 2 with Spyder 3.2.4 that installed from conda-forge channel and use all the default setting for Spyder. I tried to reinstall the Spyder from various channel but the problem is still there. Other than this error, the Spyder works without any problem. I even tried to reinstall Anaconda with the newer version of installer (after removing the old one first), but nothing change.
I already make the Python API from cocoapi, update all the Anaconda module, and make sure that the sys.path in Terminal IPython is the same with the Spyder IPython.
There is no problem when running the code on IPhython on Terminal, so it should be no problem on Spyder's IPython right? Or is there any hidden setting that I need to change?
In IPython console import the api
from pycocotools.coco import COCO
Compare Terminal IPhython with Spyder IPython
What is the expected output? What do you see instead?
This is the output of importing the code on IPython on terminal. The import worked.
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)
Type "copyright", "credits" or "license" for more information.
IPython 5.3.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: from pycocotools.coco import COCO
In [2]:
And this is when I ran the sample code on Spyder (the first line of the sample code is the same import as the above code).
Python 2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15)
Type "copyright", "credits" or "license" for more information.
IPython 5.3.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
runfile('/home/hanifr/Desktop/coco-master-linux/PythonAPI/tes_coco.py', wdir='/home/hanifr/Desktop/coco-master-linux/PythonAPI')
Traceback (most recent call last):
File "<ipython-input-1-c69dfad89653>", line 1, in <module>
runfile('/home/hanifr/Desktop/coco-master-linux/PythonAPI/tes_coco.py', wdir='/home/hanifr/Desktop/coco-master-linux/PythonAPI')
File "/home/hanifr/anaconda2/lib/python2.7/site-packages/spyder/utils/site/sitecustomize.py", line 710, in runfile
execfile(filename, namespace)
File "/home/hanifr/anaconda2/lib/python2.7/site-packages/spyder/utils/site/sitecustomize.py", line 93, in execfile
builtins.execfile(filename, *where)
File "/home/hanifr/Desktop/coco-master-linux/PythonAPI/tes_coco.py", line 1, in <module>
from pycocotools.coco import COCO
File "pycocotools/coco.py", line 55, in <module>
from . import mask as maskUtils
File "pycocotools/mask.py", line 3, in <module>
import pycocotools._mask as _mask
File "/home/hanifr/anaconda2/lib/python2.7/site-packages/pyximport/pyximport.py", line 458, in load_module
language_level=self.language_level)
File "/home/hanifr/anaconda2/lib/python2.7/site-packages/pyximport/pyximport.py", line 233, in load_module
exec("raise exc, None, tb", {'exc': exc, 'tb': tb})
File "/home/hanifr/anaconda2/lib/python2.7/site-packages/pyximport/pyximport.py", line 215, in load_module
inplace=build_inplace, language_level=language_level)
File "/home/hanifr/anaconda2/lib/python2.7/site-packages/pyximport/pyximport.py", line 191, in build_module
reload_support=pyxargs.reload_support)
File "/home/hanifr/anaconda2/lib/python2.7/site-packages/pyximport/pyxbuild.py", line 102, in pyx_to_dll
dist.run_commands()
File "/home/hanifr/anaconda2/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/home/hanifr/anaconda2/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/home/hanifr/anaconda2/lib/python2.7/site-packages/Cython/Distutils/old_build_ext.py", line 185, in run
_build_ext.build_ext.run(self)
File "/home/hanifr/anaconda2/lib/python2.7/distutils/command/build_ext.py", line 340, in run
self.build_extensions()
File "/home/hanifr/anaconda2/lib/python2.7/site-packages/Cython/Distutils/old_build_ext.py", line 193, in build_extensions
self.build_extension(ext)
File "/home/hanifr/anaconda2/lib/python2.7/distutils/command/build_ext.py", line 499, in build_extension
depends=ext.depends)
File "/home/hanifr/anaconda2/lib/python2.7/distutils/ccompiler.py", line 574, in compile
self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
File "/home/hanifr/anaconda2/lib/python2.7/distutils/unixccompiler.py", line 124, in _compile
raise CompileError, msg
ImportError: Building module pycocotools._mask failed: ["CompileError: command 'gcc' failed with exit status 1\n"]
Please provide any additional information below
I once using the default Python with Spyder2 from apt-get. The code is actually worked in that setup, but I then decided to use Anaconda with in built Spyder because I need the other module. I make sure to remove and purge the previous Spyder installation before starting to install Anaconda's Spyder.
Description of your problem
Hi,
I am currently working with an API named cocoapi that used Cython to compile .c file on Ubuntu 16.04 LTS. I can use the API flawlessly with IPython on terminal, but when run the python file on Spyder I got this error:
ImportError: Building module pycocotools._mask failed: ["CompileError: command 'gcc' failed with exit status 1\n"]
I use Anaconda 2 with Spyder 3.2.4 that installed from conda-forge channel and use all the default setting for Spyder. I tried to reinstall the Spyder from various channel but the problem is still there. Other than this error, the Spyder works without any problem. I even tried to reinstall Anaconda with the newer version of installer (after removing the old one first), but nothing change.
I already make the Python API from cocoapi, update all the Anaconda module, and make sure that the
sys.path
in Terminal IPython is the same with the Spyder IPython.There is no problem when running the code on IPhython on Terminal, so it should be no problem on Spyder's IPython right? Or is there any hidden setting that I need to change?
What steps will reproduce the problem?
from pycocotools.coco import COCO
What is the expected output? What do you see instead? This is the output of importing the code on IPython on terminal. The import worked.
And this is when I ran the sample code on Spyder (the first line of the sample code is the same import as the above code).
Please provide any additional information below I once using the default Python with Spyder2 from apt-get. The code is actually worked in that setup, but I then decided to use Anaconda with in built Spyder because I need the other module. I make sure to remove and purge the previous Spyder installation before starting to install Anaconda's Spyder.
Versions and main components
Dependencies
IPython >=4.0;<6.0: 5.4.1 (OK) cython >=0.21 : 0.26.1 (OK) jedi >=0.9.0 : 0.10.2 (OK) nbconvert >=4.0 : 5.3.1 (OK) numpy >=1.7 : 1.13.3 (OK) pandas >=0.13.1 : 0.20.3 (OK) psutil >=0.3 : 5.4.0 (OK) pycodestyle >=2.3 : 2.3.1 (OK) pyflakes >=0.5.0 : 1.6.0 (OK) pygments >=2.0 : 2.2.0 (OK) pylint >=0.25 : 1.7.4 (OK) qtconsole >=4.2.0 : 4.3.1 (OK) rope >=0.9.4 : 0.10.5 (OK) sphinx >=0.6.6 : 1.6.3 (OK) sympy >=0.7.3 : 1.1.1 (OK)
Thanks