简体   繁体   中英

Run installed package from pexpect

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM