lukeparser/pybison

Cannot compile the code in Windows

Opened this issue · 5 comments

Hello! I have tried to run the calc.py and calc1.py on my Windows OS, but I have encountered a problem.
The error I am getting is: Exception: b'The system cannot find the path specified.\r\n'
Do you have any idea why?

Thank you!
Best regards

Hey @KatyDager !
Thanks for getting in touch, can you post some more details of the error?
Have you installed pybison and verified that it works?

Hi!
The complete error is:

File "path of the calc.py file", line 276, in
p = Parser(keepfiles=args.keepfiles, verbose=args.verbose)

File "C:\Users\user\anaconda3\lib\site-packages\bison_init_.py", line 270, in init
self.engine = ParserEngine(self)

File "src/bison/cython/bison_.pyx", line 139, in bison.bison_.ParserEngine.init

File "src/bison/cython/bison_.pyx", line 177, in bison.bison_.ParserEngine.openCurrentLib

File "src/bison/cython/bison_.pyx", line 645, in bison.bison_.ParserEngine.buildLib

Exception: b'The system cannot find the path specified.\r\n'

When I tried using python -c "import bison" to check if the installation succeeded I get an invalid syntax error. The pybison package is installed tho.

Thank you for answering!

It looks like your are missing bison/flex on windows, you can use chocolatey to install those packages, e.g.

choco install mingw  # mingw is a dependency, if I remember correctly
choco install winflexbison3 --version=2.5.18.20190508  # depending the lexer/grammar code, you need to use the appropiate version, like so

You can check the installed version with win_bison --version in a terminal, or check if the library is installed.
Chocolatey should install it to C:\ProgramData\chocolatey\lib\winflexbison3\tools\)

Hope this helps!

Thank you a lot! I already had bison and flex installed (from their websites) and I installed them using chocolately.
The good part is that I do not have the same error. The bad part is that I have another one which I do not understand.

File "C:\Users\user\anaconda3\lib\distutils_msvccompiler.py", line 412, in compile
self.spawn(args)

File "C:\Users\user\anaconda3\lib\distutils_msvccompiler.py", line 518, in spawn
return super().spawn(cmd)

File "C:\Users\user\anaconda3\lib\distutils\ccompiler.py", line 910, in spawn
spawn(cmd, dry_run=self.dry_run)

File "C:\Users\user\anaconda3\lib\distutils\spawn.py", line 38, in spawn
_spawn_nt(cmd, search_path, dry_run=dry_run)

File "C:\Users\user\anaconda3\lib\distutils\spawn.py", line 80, in _spawn_nt
raise DistutilsExecError(

DistutilsExecError: command 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\bin\HostX86\x64\cl.exe' failed with exit status 2

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "calc1.py", line 276, in
p = Parser(keepfiles=args.keepfiles, verbose=args.verbose)

File "C:\Users\user\anaconda3\lib\site-packages\bison_init_.py", line 270, in init
self.engine = ParserEngine(self)

File "src/bison/cython/bison_.pyx", line 139, in bison.bison_.ParserEngine.init

File "src/bison/cython/bison_.pyx", line 177, in bison.bison_.ParserEngine.openCurrentLib

File "src/bison/cython/bison_.pyx", line 715, in bison.bison_.ParserEngine.buildLib

File "C:\Users\user\anaconda3\lib\distutils_msvccompiler.py", line 414, in compile
raise CompileError(msg)

CompileError: command 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\bin\HostX86\x64\cl.exe' failed with exit status 2

Thank you a lot for your help!

It looks like MSVC has a problem compiling the cython / C files in the project.
Unfortunately I haven't worked with MSVC in a while and I can't look into the problem right now, since I have no windows machine available. Maybe I can set something up next week.