Compile Cython Extensions Error - Pycharm IDE [duplicate]
Asked Answered
U

4

41

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.

Undersexed answered 13/11, 2017 at 5:43 Comment(1)
Does this answer your question? fatal error: Python.h: No such file or directoryAddi
U
50

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

Uninstructed answered 13/12, 2017 at 18:42 Comment(5)
If using a virtualenv you might have to do the above after activating the env.Renaldo
For RHEL / CentOS it's named "-devel", e.g. sudo yum install python36-develVivisection
In my case sudo apt-get install python3.7-dev solved the issueEdee
For Python 3.8, I had to run sudo apt-get install python3.8-devBladderwort
Thanks! Currently for python2.7 on Ubuntu use python2-devSwagerty
H
3

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

Hortense answered 25/4, 2020 at 7:16 Comment(1)
It does not work for me, "Couldn't locate package libpython3.7-dev"Glamour
T
3

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.

Traumatize answered 29/7, 2021 at 17:13 Comment(0)
W
2

Works also for Python 3.9

sudo apt-get install python3.9-dev
Winepress answered 18/6, 2021 at 9:34 Comment(1)
We don't need to add an answer for every minor version of Python. One would expect this syntax to continue to work going forward unless something changes. If it's really necessary, though, you can propose an edit to the accepted answer so include this.Moraine

© 2022 - 2024 — McMap. All rights reserved.