From ilya.kazakevich at jetbrains.com Mon Dec 9 19:03:33 2024 From: ilya.kazakevich at jetbrains.com (Ilya Kazakevich) Date: Tue, 10 Dec 2024 01:03:33 +0100 Subject: [python-win32] Using relative python path in exe files generated by `ScriptMaker` Message-ID: Hello, I create an environment on one Windows machine and then move it to another one. Once I call `pip install` it creates `.exe` files for tools i.e `poetry.exe`, `django-admin.exe` e.t.c. This is done by a class called `ScriptMaker` as I see. The problem is it sets a full path (`sys.executable`) so I can't move it to another machine or directory. To fix it I can use relative path ``` ScriptMaker.executable = "../python.exe" ``` for example, but how can I "patch" the pip? I can put this code into `sitecustomize.py` but it looks like a hack. Any suggestions on how to fix it in a proper way? Thank you in advance, Ilya. From glyph at twistedmatrix.com Tue Dec 10 00:33:59 2024 From: glyph at twistedmatrix.com (Glyph) Date: Mon, 9 Dec 2024 21:33:59 -0800 Subject: [python-win32] Using relative python path in exe files generated by `ScriptMaker` In-Reply-To: References: Message-ID: <1434A5F7-1C48-4882-9387-A8965CF10527@twistedmatrix.com> Hi Ilya, The main solution here is "don't do that". You can build binary wheels and share them between machines, but venvs are not meant to be shared. I just posted about this the other day: . Wny are you trying to copy a venv from one machine to another? -g > On Dec 9, 2024, at 4:03?PM, Ilya Kazakevich via python-win32 wrote: > > Hello, > > I create an environment on one Windows machine and then move it to another one. > Once I call `pip install` it creates `.exe` files for tools i.e > `poetry.exe`, `django-admin.exe` e.t.c. > This is done by a class called `ScriptMaker` as I see. > The problem is it sets a full path (`sys.executable`) so I can't move > it to another machine or directory. > > To fix it I can use relative path > ``` > ScriptMaker.executable = "../python.exe" > ``` > for example, but how can I "patch" the pip? > I can put this code into `sitecustomize.py` but it looks like a hack. > > Any suggestions on how to fix it in a proper way? > > Thank you in advance, > > Ilya. > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > https://mail.python.org/mailman/listinfo/python-win32 From jacob at blindza.co.za Tue Dec 10 02:15:49 2024 From: jacob at blindza.co.za (Jacob Kruger) Date: Tue, 10 Dec 2024 09:15:49 +0200 Subject: [python-win32] Using relative python path in exe files generated by `ScriptMaker` In-Reply-To: <1434A5F7-1C48-4882-9387-A8965CF10527@twistedmatrix.com> References: <1434A5F7-1C48-4882-9387-A8965CF10527@twistedmatrix.com> Message-ID: <464185c3-5346-44f9-aa4f-7b7b1701c3b0@blindza.co.za> Might not be relevant, if am misunderstanding something, but I generally just use pip freeze > requirements.txt, shift that text file over to new location/machine, create new virtual environment, and run pip install -r requirements.txt from there to recreate environment, and, I do this across different operating systems as well? Jacob Kruger Skype: BlindZA "Resistance is futile...but, acceptance is versatile..." On 2024/12/10 07:33, Glyph wrote: > Hi Ilya, > > The main solution here is "don't do that". You can build binary wheels and share them between machines, but venvs are not meant to be shared. I just posted about this the other day: . > > Wny are you trying to copy a venv from one machine to another? > > -g > >> On Dec 9, 2024, at 4:03?PM, Ilya Kazakevich via python-win32 wrote: >> >> Hello, >> >> I create an environment on one Windows machine and then move it to another one. >> Once I call `pip install` it creates `.exe` files for tools i.e >> `poetry.exe`, `django-admin.exe` e.t.c. >> This is done by a class called `ScriptMaker` as I see. >> The problem is it sets a full path (`sys.executable`) so I can't move >> it to another machine or directory. >> >> To fix it I can use relative path >> ``` >> ScriptMaker.executable = "../python.exe" >> ``` >> for example, but how can I "patch" the pip? >> I can put this code into `sitecustomize.py` but it looks like a hack. >> >> Any suggestions on how to fix it in a proper way? >> >> Thank you in advance, >> >> Ilya. >> _______________________________________________ >> python-win32 mailing list >> python-win32 at python.org >> https://mail.python.org/mailman/listinfo/python-win32 > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > https://mail.python.org/mailman/listinfo/python-win32 From glyph at twistedmatrix.com Tue Dec 10 02:45:52 2024 From: glyph at twistedmatrix.com (Glyph) Date: Mon, 9 Dec 2024 23:45:52 -0800 Subject: [python-win32] Using relative python path in exe files generated by `ScriptMaker` In-Reply-To: <464185c3-5346-44f9-aa4f-7b7b1701c3b0@blindza.co.za> References: <1434A5F7-1C48-4882-9387-A8965CF10527@twistedmatrix.com> <464185c3-5346-44f9-aa4f-7b7b1701c3b0@blindza.co.za> Message-ID: <909234AB-65F9-4B83-9ADF-E39EFA7BA977@twistedmatrix.com> > On Dec 9, 2024, at 11:15?PM, Jacob Kruger wrote: > > Might not be relevant, if am misunderstanding something, but I generally just use pip freeze > requirements.txt, shift that text file over to new location/machine, create new virtual environment, and run pip install -r requirements.txt from there to recreate environment, and, I do this across different operating systems as well? If that works for you, then yeah, that's a good way to go. The usual reason that this would not work would be if you have some native dependency with a build requirement and no binary build for your target platform, and some machines without C (or Rust, or FORTRAN, or whatever) compilers, which is particularly common on Windows. But the right way to deal with that would be `pip wheel` and copying over the wheels directory with the requirements.txt, then pip install --no-index -f wheels/ --Ur requirements.txt, not copying the virtualenv. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ilya.kazakevich at jetbrains.com Tue Dec 10 08:12:03 2024 From: ilya.kazakevich at jetbrains.com (Ilya Kazakevich) Date: Tue, 10 Dec 2024 14:12:03 +0100 Subject: [python-win32] Using relative python path in exe files generated by `ScriptMaker` In-Reply-To: <909234AB-65F9-4B83-9ADF-E39EFA7BA977@twistedmatrix.com> References: <1434A5F7-1C48-4882-9387-A8965CF10527@twistedmatrix.com> <464185c3-5346-44f9-aa4f-7b7b1701c3b0@blindza.co.za> <909234AB-65F9-4B83-9ADF-E39EFA7BA977@twistedmatrix.com> Message-ID: Hello, Thank you all. We run tests on CI and we need both Windows and Linux machines. We do not want to spend time installing lots of packages (we have lots of them) each time on each run (agents are shared and cleaned up after each run), so we use Docker on Linux. However, for Windows we can't do that, so we decided to create a `zip` archive and download it on agent. It works and it is pretty fast, and `python.exe` itself is portable. The only problem is those scripts like `poetry.exe`. From jhony1 at 126.com Thu Dec 19 20:53:35 2024 From: jhony1 at 126.com (wang) Date: Fri, 20 Dec 2024 09:53:35 +0800 (CST) Subject: [python-win32] Help, could you please help to see the below python issue? Message-ID: <4c4b789c.1924.193e1c52c64.Coremail.jhony1@126.com> Hi all, could you please help to see the below python issue? which says some dll is not a valid or workable Win32 program. thank you very much. i install python python-3.7.7-amd64.exe in win64 operation system using AMD processor , actually I have tried below solutions,but doesn't work, the issue still exists. unstall pywin32 and install pywin32-304-cp37-cp37m-win_amd64.whl. copy dll files in directory C:\Python26\Lib\site-packages\pywin32_system32\ to C:\Windows\System32. pip install matplotlib unstall python and clear it completely include in regedit, make sure no other python version installed in my PC, after that, install python and the issue still exists. [ ERROR ] Error in file 'D:\2210\ZR\Resources\resource_Common.txt' on line 4: Importing test library 'D:\2210\ZR\libs\robot_Library.py' failed: ImportError: DLL load failed: %1 ????? Win32 ????? Traceback (most recent call last): File "D:\2210\ZR\libs\robot_Library.py", line 14, in from libs.X_rndis import Rndis, ftp, IPERF File "D:\2210\ZR\libs\X_rndis.py", line 13, in import matplotlib.pyplot as plt File "C:\Users\jhony\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\__init__.py", line 109, in from . import _api, _version, cbook, docstring, rcsetup File "C:\Users\jhony\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\rcsetup.py", line 27, in from matplotlib.colors import Colormap, is_color_like File "C:\Users\jhony\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\colors.py", line 56, in from matplotlib import _api, cbook, scale File "C:\Users\jhony\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\scale.py", line 23, in from matplotlib.ticker import ( File "C:\Users\jhony\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\ticker.py", line 136, in from matplotlib import transforms as mtransforms File "C:\Users\jhony\AppData\Local\Programs\Python\Python37\lib\site-packages\matplotlib\transforms.py", line 46, in from matplotlib._path import ( PYTHONPATH: C:\Users\jhony\AppData\Local\Programs\Python\Python37\Scripts\robot.exe C:\Users\jhony\AppData\Local\Programs\Python\Python37\python37.zip C:\Users\jhony\AppData\Local\Programs\Python\Python37\DLLs C:\Users\jhony\AppData\Local\Programs\Python\Python37\lib C:\Users\jhony\AppData\Local\Programs\Python\Python37 C:\Users\jhony\AppData\Local\Programs\Python\Python37\lib\site-packages C:\Users\jhony\AppData\Local\Programs\Python\Python37\lib\site-packages\win32 C:\Users\jhony\AppData\Local\Programs\Python\Python37\lib\site-packages\win32\lib C:\Users\jhony\AppData\Local\Programs\Python\Python37\lib\site-packages\Pythonwin C:\Users\jhony\AppData\Local\Programs\Python\Python37\lib\site-packages\robotide\contrib\testrunner\../../lib D:\2210\ZR -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: 01_logs_2024-12-19_164905.zip Type: application/zip Size: 141052 bytes Desc: not available URL: