Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compile Cython Extensions Error - Pycharm IDE

Non-zero exit code (1): _pydevd_bundle/pydevd_cython.c:13:20: fatal error: Python.h: No such file or directory compilation terminated. error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

Please help me resolve this error of trying to install Cython in PyCharm.

like image 783
REDDY SARAN LAL Avatar asked Nov 13 '17 05:11

REDDY SARAN LAL


People also ask

How do I add Cython to Pycharm?

Press Ctrl+Alt+S to open the project settings and navigate to Project: <project name> | Python Interpreter. on the package toolbar, then type Cython in the search field of the Available Packages dialog, and click Install Package. Close the window upon successful installation and click OK in the interpreter settings.


Video Answer


4 Answers

JetBrains has provided an answer:

https://www.jetbrains.com/help/pycharm/2017.3/cython-speedups.html

If you're on Ubuntu, run:

For Python 2.7: sudo apt-get install python-dev

For Python 3.5: sudo apt-get install python3-dev

For Python 3.6: sudo apt-get install python3.6-dev

For Python 3.7: sudo apt-get install python3.7-dev

like image 140
Gabriel Curio Avatar answered Oct 06 '22 20:10

Gabriel Curio


For python 3.7 sudo apt install libpython3.7-dev solved my problem

like image 35
wtk300 Avatar answered Oct 06 '22 20:10

wtk300


Works also for Python 3.9

sudo apt-get install python3.9-dev
like image 42
Danny Van Geyte Avatar answered Oct 06 '22 20:10

Danny Van Geyte


Every time PyCharm makes an IDE update, I spend endless hours searching for how to do it again in Linux.

I'd like to register my answer here for my own self next time.

  1. You have to use the system python.
  2. Before anything, you have to have sudo apt-get install python<your_bin_version>-dev Obs. Use which python at usr/bin to find out.
  3. However, the system python does not recognize conda setuptools.
  4. Thus, you also need sudo apt-get install python3-setuptools

After that, if you run, the updated place of PyCharm help, as such:

sudo /usr/bin/python3 /<your_pycharm_installation_dir>/pycharm-2021.1/plugins/python/helpers/pydev/setup_cython.py build_ext --inplace

Then, and only then, it works ... (but only for the base python).

Next, I found the recently constructed directory /_pydevd_bundle and manually (yeah) copied it into

/<your conda environmenbt>/.conda/envs/py39web/compiler_compat

Except for jupyter notebooks, though.

like image 34
B Furtado Avatar answered Oct 06 '22 20:10

B Furtado