Python Forum
ImportError: cannot import name 'MidiEvaluator' from 'parser' (Windows 10)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ImportError: cannot import name 'MidiEvaluator' from 'parser' (Windows 10)
#1
Hello,

- Clean Python 3.8.3 installation on Windows 10: uninstalled any previous python versions and installed it using "install now" (without selecting "Add Python 3.8 to path")

- Cloned tbon project (https://github.com/gianmarialari/tbon.git)

- According to project author, tbon needs the following third-party libraries to run: parsimonious, midiutil, pytest. So I did this:

Output:
py -m pip install parsimonious py -m pip install midiutil py -m pip install pytest
Now tbon should work but it doesn't. Here it is the output when I try to execute it:

Error:
C:\Users\Gianmaria\Documents\GitHub\tbon>py tbon.py Traceback (most recent call last): File "tbon.py", line 12, in <module> from parser import MidiEvaluator ImportError: cannot import name 'MidiEvaluator' from 'parser' (unknown location)
Tried also with Python 3.8.1 (always on windows) without success.
The same thing on linux works without any issue.

Just in case you need:

Output:
C:\Users\Gianmaria\Documents\GitHub\tbon>py Python 3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:37:02) [MSC v.1924 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> sys.path ['', 'C:\\Users\\Gianmaria\\AppData\\Local\\Programs\\Python\\Python38\\python38.zip', 'C:\\Users\\Gianmaria\\AppData\\Local\\Programs\\Python\\Python38\\DLLs', 'C:\\Users\\Gianmaria\\AppData\\Local\\Programs\\Python\\Python38\\lib', 'C:\\Users\\Gianmaria\\AppData\\Local\\Programs\\Python\\Python38', 'C:\\Users\\Gianmaria\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages'] >>>
Any suggestion?
P.S. This is my first post here. Tried to follow the python forum rules but if I made any mistake please let me know.
Reply
#2
What do you see if you type this at the python prompt?
import parser
dir(parser)
Somewhere there should be MidiEvaluator

parser.py imports keysigs and parsimonious.grammer. You should try importing those from the command line
import keysigs
import parsimonious.grammar
Any errors?
Reply
#3
There is a conflict with standard library parser and parser.py named in project.
Rename parser.py to midi_parser.py,in root of project.
Then in tbon.py line-12 change to.
from midi_parser import MidiEvaluator
The Path stuff you show has really nothing to do with the error
You should fix path so also Scripts is in Path,so pip work from anywhere in cmd.
# Okay
C:\\Users\\Gianmaria\\AppData\\Local\\Programs\\Python\\Python38

# Add the place where pip is,only one \ when edit in Windows
C:\\Users\\Gianmaria\\AppData\\Local\\Programs\\Python\\Python38\\Scripts
Look at Python 3.8 (3.6-3.7) and pip installation under Windows
Reply
#4
Thank you Snippsat and Deanhystad for your help!

Snippsat, you were right. I made the change and now I'm able to run the program.

A couple of questions:

- doesn't exist any tool that checks the code and warn about potential name conflicts?

- how did you know that my path didn't contain the Python38\Scripts and Python38\ ?

- To add to the windows path the two missing directory, I decided to do what it is suggested in the manual: <<[...] If you don’t enable this option at install time, you can always re-run the installer, select Modify, and enable it>>. Now the (user) windows path contains the following:
C:\Users\Gianmaria\AppData\Local\Programs\Python\Python38\Scripts\
C:\Users\Gianmaria\AppData\Local\Programs\Python\Python38\
C:\Users\Gianmaria\AppData\Roaming\Python\Scripts
Is the last line correct?

Thanks a lot for you help, Gianmaria
Reply
#5
(May-22-2020, 09:11 PM)spiffspaceman Wrote: - how did you know that my path didn't contain the Python38\Scripts and Python38\ ?
You did show sys.path output.
(May-22-2020, 09:11 PM)spiffspaceman Wrote: Is the last line correct?
Two first one is correct look at image in link.
The test is that python and pip shall work from any folder path in cmd.
C:\code>python -V
Python 3.8.3

C:\code>pip -V
pip 20.1.1 from c:\python38\lib\site-packages\pip (python 3.8)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question Cannot import easysnmp: ImportError: libnetsnmp.so.30 Calab 4 999 Jun-08-2023, 08:52 PM
Last Post: Gribouillis
  ImportError: cannot import name 'Pyfhel' from 'Pyfhel' Anldra12 9 3,446 Dec-13-2021, 06:55 PM
Last Post: Anldra12
  ImportError: cannot import name 'get_config' russray2008 0 4,679 Sep-20-2021, 02:18 PM
Last Post: russray2008
  ImportError: cannot import name 'Union' from '_ctypes' (unknown location) ciuffoly 15 10,263 Oct-09-2020, 06:58 AM
Last Post: ciuffoly
  ImportError: cannot import name 'Request' from 'request' abhishek81py 1 3,860 Jun-18-2020, 08:07 AM
Last Post: buran
  ImportError: cannot import name 'X ' from ' Y' (Unknown location) Arjunpi 1 4,320 Apr-30-2020, 12:56 AM
Last Post: Larz60+
  problem with mapnik in anaconda python 2: from _mapnik import * ImportError: DLL load parsley 0 1,873 Dec-11-2019, 07:50 AM
Last Post: parsley
  getting ImportError: cannot import name 'HAProxyServer' deepakkr3110 0 1,619 Nov-12-2019, 07:48 AM
Last Post: deepakkr3110
  ImportError: cannot import name 'gui' from 'appJar' CabbageMan 1 2,793 Sep-04-2019, 07:31 PM
Last Post: Gribouillis
Question python parser windows firewall log Jonub 0 2,019 Jul-16-2019, 06:36 PM
Last Post: Jonub

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020