0

I have downloaded pyocd and built it successfully. Now I am able to run the tool from command line from any location. However when try to run it using pexpect it shows following error:

Traceback (most recent call last):
  File "c:\Users\elephant\AppData\Local\Programs\Python\Python37-32\Scripts\pyocd-script.py", line 6, in <module>
    from pkg_resources import load_entry_point
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 668, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 638, in _load_backward_compatible
  File "C:\Projects\runner\mytest\venv\lib\site-packages\setuptools-39.1.0-py3.7.egg\pkg_resources\__init__.py", line 3086, in <module>
  File "C:\Projects\runner\mytest\venv\lib\site-packages\setuptools-39.1.0-py3.7.egg\pkg_resources\__init__.py", line 3070, in _call_aside
  File "C:\Projects\runner\mytest\venv\lib\site-packages\setuptools-39.1.0-py3.7.egg\pkg_resources\__init__.py", line 3099, in _initialize_master_working_set
  File "C:\Projects\runner\mytest\venv\lib\site-packages\setuptools-39.1.0-py3.7.egg\pkg_resources\__init__.py", line 574, in _build_master
  File "C:\Projects\runner\mytest\venv\lib\site-packages\setuptools-39.1.0-py3.7.egg\pkg_resources\__init__.py", line 892, in require
  File "C:\Projects\runner\mytest\venv\lib\site-packages\setuptools-39.1.0-py3.7.egg\pkg_resources\__init__.py", line 778, in resolve
pkg_resources.DistributionNotFound: The 'pyocd==0.14.1.dev277+dirty' distribution was not found and is required by the application

Please help to understand what is wrong and why it works from command line?

Elephant
  • 675
  • 1
  • 8
  • 18
  • It sounds like the `$PYTHONPATH` variable is not set correctly. Or perhaps you installed an inconsistent version? `.dev277+dirty` sounds a bit strange, did you install from a git repository? – Martin Ueding Mar 14 '19 at 08:44
  • @MartinUeding You are right this was custom build. I have just cloned sources from Git and built it. The behavior is the same, but different version: `pkg_resources.DistributionNotFound: The 'pyocd==0.17.1.dev71' distribution was not found and is required by the application` – Elephant Mar 14 '19 at 08:55
  • @MartinUeding There is no `$PYTHONPATH` variable at all. pyocd executable located in `c:\Users\elephant\AppData\Local\Programs\Python\Python37-32\Scripts`. – Elephant Mar 14 '19 at 09:37
  • Version is correct `c:\>pyocd -V` output is `0.17.1.dev71` – Elephant Mar 14 '19 at 11:06

1 Answers1

0

The problem was that I tried to spawn pyocd.exe and pexpect was not able to find the package. I changed the line to python -m pyocd and it just works fine. I am new in Python and mistakenly thought that exe is compiled code as the other exe files in Windows. However, it is just an instruction to run the package using Python.

Elephant
  • 675
  • 1
  • 8
  • 18