Cython setup error : Unable to find pgen, not compiling formal grammar
Asked Answered
C

6

7

In order to install cython ( for python 2.7 , windows 8.1 ), made the download in .zip format, extracted the whole file and run the setup.py . Thus, python shell shows this : Unable to find pgen, not compiling formal grammar.

What is the problem and how it can be solved ?

Canyon answered 30/1, 2016 at 0:3 Comment(2)
Please see if this helps which looks similar to you.Bureau
It should be possible to install and use Cython regardless of that message.Idolah
I
4

The relevant code in setup.py first tries to find pgen

 pgen = find_executable(
        'pgen', os.pathsep.join([os.environ['PATH'], os.path.join(get_python_inc(), '..', 'Parser')]))
    if not pgen:
        print ("Unable to find pgen, not compiling formal grammar.")

If pgen is found, then file Cython/Parser/Grammar is given as argument to pgen

    else:
        parser_dir = os.path.join(os.path.dirname(__file__), 'Cython', 'Parser')
        grammar = os.path.join(parser_dir, 'Grammar')
        subprocess.check_call([
            pgen,
            os.path.join(grammar),
            os.path.join(parser_dir, 'graminit.h'),
            os.path.join(parser_dir, 'graminit.c'),
            ])

The first lines of Cython/Parser/Grammar,

# Grammar for Cython, based on the Grammar for Python 3

# Note: This grammar is not yet used by the Cython parser and is subject to change.

That comment seems to suggests that even if pgen is available, the code produced by it won't be used.

Idolah answered 30/1, 2016 at 19:41 Comment(0)
C
4

Much Simpler,

Try installing Cython from pip. Windows- Open Python folder, press shift+right click, select "open command promt here"

pip install cython

Coconut answered 30/5, 2016 at 10:35 Comment(0)
H
1

I had the same problem in ubuntu. I first tried

sudo easy_install cython

It failed

Then I did it manually in the following manner:

mkdir cython
cd cython
wget http://cython.org/release/Cython-0.24.zip
unzip Cython-0.24.zip
cd Cython-0.24
sudo python setup.py install
Heaviness answered 28/4, 2016 at 12:1 Comment(0)
A
1

If installing Cython on Raspberry Pi and you get the error

unable to find pgen

I found that installing pgen manually then running the Cython install worked!

sudo pip3 install pgen
Almuce answered 4/6, 2018 at 19:48 Comment(0)
B
0

Try folollowing command,

sudo apt-get install build-essential python-dev python-pip libev4 libev-dev
sudo apt-get install cython3
Brown answered 16/11, 2017 at 6:55 Comment(0)
V
0

For me, the following install option solved the problem:

pip install Cython==0.29.1 --install-option="--no-cython-compile"
Variola answered 13/4, 2023 at 5:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.