pythonabstract-syntax-tree

Anaconda3 or Anaconda 2 install is not functioning due to ast node parsing errors


operating system: Windows 10 Enterprise on a virtual machine All of the installations were done for user (myself) only.

I had previously installed Anaconda 3 and Anaconda 2 versions (not sure which ones). Due to some issues, I had to reinstall Anaconda 2 (Anaconda2-4.0.0-Windows-x86_64.exe). Post installation, the installation could invoke the python. However, the installation was not usable as import pandas would fail due to ast module node traversing fails (sorry for not explaining this better - snippet of similar error below).

Post this fail, I uninstalled Anaconda2, and installed Anaconda3 (Anaconda3-2024.02-1-Windows-x86_64.exe). The installation did not work until environmental PATH was updated with the location of the python installation.

Invoking python interpreter worked fine. However, invoking conda from command prompt or importing pandas fails with error:

(snip full traceback error)

  File "C:\Users\idsid\AppData\Local\anaconda3\Lib\inspect.py", line 1024, in <module>
    class _ClassFinder(ast.NodeVisitor):
                       ^^^^^^^^^^^^^^^
AttributeError: module 'ast' has no attribute 'NodeVisitor'

Some research (ast and working directory) shows that ast.NodeVisitior could fail due to inclusion of working directory in the path. However, if the Anaconda3 path is not in the PATH variable, conda cannot be invoked from command line.

My expectation is to understand how to fix the issue and use the Anaconda / conda.

Needless to say, any help would be appreciated.


Solution

  • A good night's sleep got me an answer. In the above steps I have also added PYTHONPATH variable pointing to a custom script paths. That resulted, most likely, in also having ast.py in that path causing the collision between Anaconda install and the new paths. Removing them fixed the issue!