pybind/python_example

Install compiled package in a Jupyter Notebook

Closed this issue · 2 comments

When trying to install the package in a VM that runs Jupyter , I get:

Building wheels for collected packages: python-example
  Building wheel for python-example (pyproject.toml) ... error
  ERROR: Command errored out with exit status 1:
   command: /opt/conda/bin/python3.9 /opt/conda/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py build_wheel /tmp/tmp9_ynf75e
       cwd: /tmp/pip-install-m83247_q/python-example_7e361d0b50f14aa5b1656c0b195516e2
  Complete output (63 lines):
running bdist_wheel
  running build
  running build_ext
  gcc -pthread -B /opt/conda/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /opt/conda/include -fPIC -O2 -isystem /opt/conda/include -fPIC -I/opt/conda/include/python3.9 -c flagcheck.cpp -o flagcheck.o -std=c++17
  gcc: fatal error: cannot execute ‘cc1plus’: execvp: No such file or directory
  compilation terminated.
  gcc -pthread -B /opt/conda/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /opt/conda/include -fPIC -O2 -isystem /opt/conda/include -fPIC -I/opt/conda/include/python3.9 -c flagcheck.cpp -o flagcheck.o -std=c++14
  gcc: fatal error: cannot execute ‘cc1plus’: execvp: No such file or directory
  compilation terminated.
  gcc -pthread -B /opt/conda/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /opt/conda/include -fPIC -O2 -isystem /opt/conda/include -fPIC -I/opt/conda/include/python3.9 -c flagcheck.cpp -o flagcheck.o -std=c++11
  gcc: fatal error: cannot execute ‘cc1plus’: execvp: No such file or directory
  compilation terminated.
  Traceback (most recent call last):
    File "/opt/conda/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
      main()
    File "/opt/conda/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "/opt/conda/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 261, in build_wheel
      return _build_backend().build_wheel(wheel_directory, config_settings,
    File "/tmp/pip-build-env-2d19eif2/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 413, in build_wheel
      return self._build_with_temp_dir(['bdist_wheel'], '.whl',
    File "/tmp/pip-build-env-2d19eif2/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 398, in _build_with_temp_dir
      self.run_setup()
    File "/tmp/pip-build-env-2d19eif2/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 335, in run_setup
      exec(code, locals())
    File "<string>", line 27, in <module>
    File "/tmp/pip-build-env-2d19eif2/overlay/lib/python3.9/site-packages/setuptools/__init__.py", line 87, in setup
      return distutils.core.setup(**attrs)
    File "/tmp/pip-build-env-2d19eif2/overlay/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 185, in setup
      return run_commands(dist)
    File "/tmp/pip-build-env-2d19eif2/overlay/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
      dist.run_commands()
    File "/tmp/pip-build-env-2d19eif2/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
      self.run_command(cmd)
    File "/tmp/pip-build-env-2d19eif2/overlay/lib/python3.9/site-packages/setuptools/dist.py", line 1208, in run_command
      super().run_command(command)
    File "/tmp/pip-build-env-2d19eif2/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
      cmd_obj.run()
    File "/tmp/pip-build-env-2d19eif2/normal/lib/python3.9/site-packages/wheel/bdist_wheel.py", line 325, in run
      self.run_command("build")
    File "/tmp/pip-build-env-2d19eif2/overlay/lib/python3.9/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
      self.distribution.run_command(command)
    File "/tmp/pip-build-env-2d19eif2/overlay/lib/python3.9/site-packages/setuptools/dist.py", line 1208, in run_command
      super().run_command(command)
    File "/tmp/pip-build-env-2d19eif2/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
      cmd_obj.run()
    File "/tmp/pip-build-env-2d19eif2/overlay/lib/python3.9/site-packages/setuptools/_distutils/command/build.py", line 132, in run
      self.run_command(cmd_name)
    File "/tmp/pip-build-env-2d19eif2/overlay/lib/python3.9/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
      self.distribution.run_command(command)
    File "/tmp/pip-build-env-2d19eif2/overlay/lib/python3.9/site-packages/setuptools/dist.py", line 1208, in run_command
      super().run_command(command)
    File "/tmp/pip-build-env-2d19eif2/overlay/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
      cmd_obj.run()
    File "/tmp/pip-build-env-2d19eif2/overlay/lib/python3.9/site-packages/setuptools/command/build_ext.py", line 84, in run
      _build_ext.run(self)
    File "/tmp/pip-build-env-2d19eif2/overlay/lib/python3.9/site-packages/setuptools/_distutils/command/build_ext.py", line 346, in run
      self.build_extensions()
    File "/tmp/pip-build-env-2d19eif2/overlay/lib/python3.9/site-packages/pybind11/setup_helpers.py", line 288, in build_extensions
      ext.cxx_std = auto_cpp_level(self.compiler)
    File "/tmp/pip-build-env-2d19eif2/overlay/lib/python3.9/site-packages/pybind11/setup_helpers.py", line 271, in auto_cpp_level
      raise RuntimeError(msg)
  RuntimeError: Unsupported compiler -- at least C++11 support is needed!
  ----------------------------------------
  ERROR: Failed building wheel for python-example
Failed to build python-example
ERROR: Could not build wheels for python-example, which is required to install pyproject.toml-based projects

It looks like you aren't adding the compiler package to conda, so you can't compile anything. Conda has its own compiler packages, it doesn't use the system. Conda forge has a "compilers" metapackage, otherwise you'll need the appropriate packages for your system. In general, Conda's really not designed to compile things outside of Conda-build and conda recipes.

Thanks henry, that would make sense. So my best bet would be working with another Docker image to run the package from Jupyter. Closing the issue for now.