I'm using VSCode with Python 3.11.0 in a virtual enviroment. I have installed the aforementioned toolchain to configure and launch LTSpice models.
However, it seems not to work and I cannot find why (I'm quite new to python programming). I attach here the actual code and the traceback. Notice that the main code is taken from the example given in its webpage.
The code:
import os
from PyLTSpice.LTSpiceBatch import SimCommander
# get script absolute path
meAbsPath = os.path.dirname(os.path.realpath("Draft1.asc"))
meAbsPath = meAbsPath + '/Draft1.asc'
print(str(meAbsPath))
# select spice model
LTC = SimCommander(meAbsPath)
# set default arguments
# LTC.set_parameters(res=0, cap=100e-6)
LTC.set_component_value('R1', '2k')
LTC.set_component_value('L1', '1u')
# LTC.set_element_model('V3', "SINE(0 1 3k 0 0 0)")
# define simulation
LTC.add_instructions(
"; Simulation settings",
".param run = 0"
)
LTC.reset_netlist()
LTC.add_instructions(
"; Simulation settings",
".tran 0 10u 0 1n",
)
LTC.run()
LTC.wait_completion()
# Sim Statistics
print('Successful/Total Simulations: ' + str(LTC.okSim) + '/' + str(LTC.runno))
The traceback log:
(.venv) PS C:\Users\ciko9\Documents\VSCode_Projects\.venv> c:; cd 'c:\Users\ciko9\Documents\VSCode_Projects\.venv'; & 'c:\Users\ciko9\Documents\VSCode_Projects\.venv\Scripts\python.exe' 'c:\Users\ciko9\.vscode\extensions\ms-python.python-2022.18.2\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher' '51647' '--' 'c:\Users\ciko9\Documents\VSCode_Projects\.venv\lts_run.py'
C:\Users\ciko9\Documents\VSCode_Projects\.venv/Draft1.asc
Creating Netlist
Traceback (most recent call last):
File "C:\Users\ciko9\AppData\Local\Programs\Python\Python311\Lib\runpy.py", line 198, in _run_module_as_main
return _run_code(code, main_globals, None,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ciko9\AppData\Local\Programs\Python\Python311\Lib\runpy.py", line 88, in _run_code
exec(code, run_globals)
File "c:\Users\ciko9\.vscode\extensions\ms-python.python-2022.18.2\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher/../..\debugpy\__main__.py", line 39, in
cli.main()
File "c:\Users\ciko9\.vscode\extensions\ms-python.python-2022.18.2\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 430, in main
run()
File "c:\Users\ciko9\.vscode\extensions\ms-python.python-2022.18.2\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 284, in run_file
runpy.run_path(target, run_name="__main__")
File "c:\Users\ciko9\.vscode\extensions\ms-python.python-2022.18.2\pythonFiles\lib\python\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 321, in run_path
return _run_module_code(code, init_globals, run_name,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\ciko9\.vscode\extensions\ms-python.python-2022.18.2\pythonFiles\lib\python\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 135, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "c:\Users\ciko9\.vscode\extensions\ms-python.python-2022.18.2\pythonFiles\lib\python\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 124, in _run_code
exec(code, run_globals)
File "c:\Users\ciko9\Documents\VSCode_Projects\.venv\lts_run.py", line 11, in
LTC = SimCommander(meAbsPath)
^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\ciko9\Documents\VSCode_Projects\.venv\Lib\site-packages\PyLTSpice\LTSpiceBatch.py", line 288, in __init__
retcode = run_function(cmd_netlist)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\ciko9\Documents\VSCode_Projects\.venv\Lib\site-packages\PyLTSpice\LTSpiceBatch.py", line 136, in run_function
result = subprocess.run(command, timeout=timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ciko9\AppData\Local\Programs\Python\Python311\Lib\subprocess.py", line 546, in run
with Popen(*popenargs, **kwargs) as process:
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ciko9\AppData\Local\Programs\Python\Python311\Lib\subprocess.py", line 1022, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\ciko9\AppData\Local\Programs\Python\Python311\Lib\subprocess.py", line 1491, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\ciko9\.vscode\extensions\ms-python.python-2022.18.2\pythonFiles\lib\python\debugpy\_vendored\pydevd\_pydev_bundle\pydev_monkey.py", line 853, in new_CreateProcess
return getattr(_subprocess, original_name)(app_name, cmd_line, *args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [WinError 2] El sistema no puede encontrar el archivo especificado
I guess that it actually finds the ".asc" LTSpice model file, but at some point it misses something but I could not figure out what is it. Thanks in advance!