pycscope
pycscope copied to clipboard
Cannot install: No module named 'parser'
When I try to install, I get the following output:
[user ~/github/pycscope]$ python setup.py install
Traceback (most recent call last):
File "/home/user/github/pycscope/setup.py", line 5, in <module>
from pycscope import __version__
File "/home/user/github/pycscope/pycscope/__init__.py", line 25, in <module>
import keyword, parser, symbol, token
ModuleNotFoundError: No module named 'parser'
I think the issue is basically that pycscope cannot be run using Python 3.10 because the parser module has been removed. It works on Python 3.8 and older, though.
Ugh.
That's not the only thing that is gone in 3.10, so is the symbol module.
Hi Peter!
And at least one new distro (Ubuntu 22.04) is 3.10+ only now ;-( I guess ast is the closest replacement? I might have to start looking at this as I use it every day, until then can generate cscope.out files on an older system.
Any help you can offer would be great. I have not had a chance to dive into this work for a long time now.
@portante The parser
module has been deprecated since Python 3.10. The only way left is the ast
(abstract syntax tree) module. However, I think pycscope requires a concrete syntax tree that preserves the original source code, rather than an abstract syntax tree that's lossy. So, instead of using the ast
module, you may need something like LibCST
.
@portante oh. I'm mistaken. There might be a far simpler way to fix this. Please see this page. The change looks trivial. They simply replaced parser.suite
with ast.parse
.
@portante I tried it, but it doesn't work. I think the old tuple structure is no longer used. Looks like you have no other choice but to port pycscope to ast
or LibCST
, which is a huge change to pycscope. It's almost a rewrite I expect. The other alternative is for you to get the old parser
and symbol
modules' source code from 3.9 and incorporate it into pycscope.