cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
lala
Level VIII

Does mitmproxy not work in python installed in JMP environment?

I checked with 

jmputils.jpip('list')


mitmproxy was successfully installed

2024-09-21_09-22-03.png

But it doesn't work in python code.

Thanks!

9 REPLIES 9

Re: Does mitmproxy not work in python installed in JMP environment?

Doesn't work in what way?  Does import mitmproxy fail? If so try restarting JMP and seeing if it's now visible to JMP.  Otherwise how about an example?   What have you tried and why doesn't it do what you are expecting?

Re: Does mitmproxy not work in python installed in JMP environment?

Note to all: The package mitmproxy is a Man-In-the-Middle HTTPS/TLS web proxy for intercepting web traffic.  I'm assuming the use case here is separately launched mitmproxy and use of JMP and mitmproxy's Python-API to control the proxy from JMP.

lala
Level VIII

Re: Does mitmproxy not work in python installed in JMP environment?

Yes, I want to use this mitmproxy to replace Selenium for packet capture.
Maybe I have not set up the computer proxy server cause.And python is written by GPT-4o.
I'll check first.

Thanks Experts!

lala
Level VIII

Re: Does mitmproxy not work in python installed in JMP environment?

But the following PY code will work fine for other people using python in a non-JMP environment.
But I've never been successful running python in a JMP environment.Attempts to install different versions of these libraries also failed.

 

error


C:\Users\Administrator\AppData\Roaming\JMP\JMP\Python\Python311\site-packages\pywinauto\__init__.py:71: UserWarning: Apply externally defined coinit_flags: 2
  warnings.warn("Apply externally defined coinit_flags: {0}"

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\Administrator\AppData\Roaming\JMP\JMP\Python\Python311\site-packages\pywinauto\__init__.py", line 89, in <module>
    from . import findwindows
  File "C:\Users\Administrator\AppData\Roaming\JMP\JMP\Python\Python311\site-packages\pywinauto\findwindows.py", line 42, in <module>
    from . import controls
  File "C:\Users\Administrator\AppData\Roaming\JMP\JMP\Python\Python311\site-packages\pywinauto\controls\__init__.py", line 36, in <module>
    from . import uiawrapper # register "uia" back-end (at the end of uiawrapper module)
    ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Roaming\JMP\JMP\Python\Python311\site-packages\pywinauto\controls\uiawrapper.py", line 47, in <module>
    from ..uia_defines import IUIA
  File "C:\Users\Administrator\AppData\Roaming\JMP\JMP\Python\Python311\site-packages\pywinauto\uia_defines.py", line 181, in <module>
    pattern_ids = _build_pattern_ids_dic()
                  ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Roaming\JMP\JMP\Python\Python311\site-packages\pywinauto\uia_defines.py", line 169, in _build_pattern_ids_dic
    if hasattr(IUIA().ui_automation_client, cls_name):
               ^^^^^^
  File "C:\Users\Administrator\AppData\Roaming\JMP\JMP\Python\Python311\site-packages\pywinauto\uia_defines.py", line 50, in __call__
    cls._instances[cls] = super(_Singleton, cls).__call__(*args, **kwargs)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Roaming\JMP\JMP\Python\Python311\site-packages\pywinauto\uia_defines.py", line 60, in __init__
    self.UIA_dll = comtypes.client.GetModule('UIAutomationCore.dll')
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Roaming\JMP\JMP\Python\Python311\site-packages\comtypes\client\_generate.py", line 153, in GetModule
    return _create_friendly_module(tlib, modulename)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Roaming\JMP\JMP\Python\Python311\site-packages\comtypes\client\_generate.py", line 218, in _create_friendly_module
    _invalidate_import_caches()
  File "C:\Users\Administrator\AppData\Roaming\JMP\JMP\Python\Python311\site-packages\comtypes\client\_generate.py", line 189, in _invalidate_import_caches
    importlib.invalidate_caches()
  File "importlib\__init__.py", line 70, in invalidate_caches
    finder.invalidate_caches()
  File "<frozen importlib._bootstrap_external>", line 1409, in invalidate_caches
TypeError: MetadataPathFinder.invalidate_caches() missing 1 required positional argument: 'cls'

PY

from pywinauto.application import Application
from pywinauto import timings
import pandas as pd
import time
import datetime
import os
import psutil
lala
Level VIII

Re: Does mitmproxy not work in python installed in JMP environment?

  • There are specific python code files.

Thanks Experts!

Re: Does mitmproxy not work in python installed in JMP environment?

Attempts to install different versions of these libraries also failed.

 

As has been mentioned a couple of times in some of the other Python discussion posts, there is an issue in JMP 18.0 installing some packages. If the install fails due to a _socket cannot be found error, this is a known issue.  It has been resolved in 18.1, but you need to do an uninstall of JMP 18.0 and a clean install of 18.1. The update / repair does not move the necessary files.  

 

The workaround in 18.0 is to go to the JMP install directory create a DLLs\ directory, move all the .pyd into the DLLs directory and some dlls. These are: libcrypto, libssl, libffi, and sqlite3.  They have version numbers in the name.  Move these files to the DLLs directory as well. This should fix the failure to install due to the can't find _socket error.  pywinauto should install after that fix or by reinstalling using 18.1

 

Re: Does mitmproxy not work in python installed in JMP environment?

I have tried this on my machine, and I successfully installed all the packages, and I also get the error message when attempting to run from JMP.

TypeError: MetadataPathFinder.invalidate_caches() missing 1 required positional argument: 'cls'

 

Searching on that string indicates it's a coding error within the package.  I see the behavior, I can do the import from standalone Python, and the error from JMP.  But in this case it appears the environment because it's running from within embedded Python makes the package take a different code path.  You could submit a bug / issue to the project.  GitHub - pywinauto/pywinauto: Windows GUI Automation with Python (based on text properties) However, pywinauto appears to be an abandoned project.  No commits in 2+ years. Looking at the issue tracker there also appears to be issues with it running on Win 11.  One of my co-workers is working on a project that utilizes Window's UI Automation to add capabilities to our own testing suite.  However, there are significant issues even in C++ of calling the UI Automation from within the application you are automating.  This could be having an effect as well. It's unlikely the author(s) of pywinauto tested or tried running from within embedded Python.

 

Sorry looks like running pywinauto from within JMP or any embedded Python instance is dead-end.

lala
Level VIII

Re: Does mitmproxy not work in python installed in JMP environment?

Thanks Experts!

 

I am jmp 18.1 for win10.

lala
Level VIII

Re: Does mitmproxy not work in python installed in JMP environment?

If I want to install python separately, how can I make its library use the original JMP environment python library?

Thanks Experts!

C:\Users\Administrator\AppData\Roaming\JMP\JMP\Python\Python311\Scripts
C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\venv\scripts