Skip to content
This repository has been archived by the owner on Jul 15, 2022. It is now read-only.

name 'Environment' is not defined / name 'HtmlFormatter' is not defined #3

Open
matzl opened this issue May 25, 2022 · 1 comment
Open

Comments

@matzl
Copy link

matzl commented May 25, 2022

Hi,

I tried running the script as proposed here in the docs but I only receive error messages.
First I got:

D:\Git\gearshift_calculation_tool>gearshift run "inputs/gs_input_demo.xlsx" -O "outputs/2022-05-25_demo"
  0%|                                                                                                                                                                                                                        | 0/1 [00:00<?, ?it/s]: Processing D:\Git\gearshift_calculation_tool\inputs\gs_input_demo.xlsx
2022-05-25 18:04:59,621:ERROR:schedula.utils.sol:Failed DISPATCHING 'load_inputs/parse_excel_file' due to:
  ValueError('Unknown engine: openpyxl')
Traceback (most recent call last):
  File "c:\users\my_username\appdata\local\programs\python\python37\lib\site-packages\schedula\utils\sol.py", line 632, in _evaluate_node
    **kw)
  File "c:\users\my_username\appdata\local\programs\python\python37\lib\site-packages\schedula\utils\sol.py", line 606, in _evaluate_function
    verbose=self.verbose
  File "c:\users\my_username\appdata\local\programs\python\python37\lib\site-packages\schedula\utils\asy\__init__.py", line 202, in async_process
    exe_id, funcs, executor, *args, **kw
  File "c:\users\my_username\appdata\local\programs\python\python37\lib\site-packages\schedula\utils\asy\__init__.py", line 159, in _process_funcs
    r['res'] = e.process(sid, fn, *args, **kw) if e else fn(*args, **kw)
  File "d:\git\gearshift_calculation_tool\gearshift\core\load\excel.py", line 148, in parse_excel_file
    input_data = pd.ExcelFile(input_file, engine="openpyxl")
  File "c:\users\my_username\appdata\local\programs\python\python37\lib\site-packages\pandas\io\excel.py", line 369, in __init__
    raise ValueError("Unknown engine: {engine}".format(engine=engine))
ValueError: Unknown engine: openpyxl

...which I could fix by downgrading some of the required packages (I think I changed "pandas>=0.21.0" to "pandas==0.21.0" in the setup.py) and created a virtual environment with this in PyCharm.
However, I still have multiple error messages left:

Executing gearshift model: 100%|██████████| 1/1 [00:02<00:00,  2.53s/it]
name 'Environment' is not defined
name 'HtmlFormatter' is not defined
name 'HtmlFormatter' is not defined
name 'HtmlFormatter' is not defined
name 'HtmlFormatter' is not defined
name 'HtmlFormatter' is not defined
name 'HtmlFormatter' is not defined
name 'Environment' is not defined
name 'HtmlFormatter' is not defined
name 'HtmlFormatter' is not defined
name 'HtmlFormatter' is not defined
name 'HtmlFormatter' is not defined
name 'HtmlFormatter' is not defined
name 'HtmlFormatter' is not defined
name 'HtmlFormatter' is not defined
Traceback (most recent call last):
  File "D:/Git/gearshift_calculation_tool/run_this_script.py", line 7, in <module>
    core.plot()
  File "D:\Git\gearshift_calculation_tool\venv\lib\site-packages\schedula\utils\base.py", line 282, in plot
    executor=executor
  File "D:\Git\gearshift_calculation_tool\venv\lib\site-packages\schedula\utils\drw\__init__.py", line 1669, in render
    self._view(fpath, format=osp.splitext(fpath)[1][1:], quiet=True)
  File "D:\Git\gearshift_calculation_tool\venv\lib\site-packages\graphviz\files.py", line 300, in _view
    view_method(filepath, quiet)
  File "D:\Git\gearshift_calculation_tool\venv\lib\site-packages\graphviz\backend.py", line 376, in view_windows
    os.startfile(filepath)
FileNotFoundError: [WinError 2] Das System kann die angegebene Datei nicht finden: 'C:\\Users\\my_username\\AppData\\Local\\Temp\\tmpoumbf9no\\core.html'

Process finished with exit code 1

I think it has something to do with the Pygments package? I don't know where exactly I can add the "not defined" names...? I also tried downgrading Pygments using "Pygments==2.8.1".

My script looks like this (as the example in the docs):

from gearshift.core import dsp
import schedula as sh

vehData = 'inputs/gs_input_demo2.xlsx'
my_input = dict(input_file_name=vehData)
core = dsp(my_input, outputs=['sol'], shrink=True)
core.plot()  # script stops during execution of this line
solution = sh.selector(['sol'], sh.selector(['sol'], core))

# Select gears output for different cases
gears = {}
for sol in solution['sol']:
    gears[f'gears_{sol["Case"]}'] = sol['GearsOutput']

Any clue on how I can make the script running? Thank you!

Best regards,
Matthias

@AndresLaverdeMarin
Copy link
Member

Hello @matzl,

Sorry for my late response, to solve this problem you need to run:

pip install schedula[all]

And after that run again your script, this will solve your problem.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants