3

I created an application using PyQt5, and I'm willing to convert it to a 32bit executable file (.exe) using auto-py-to-exe! I searched a lot about this and figured out that I should use a 32bit version of Python for this purpose(examples:[1],[2],[3],[4]). Since I'm comfortable with using Conda environments, I tried to make a clone from my preferred Conda environment(that contains PyQt5 and auto-py-to-exe) in this way:

set CONDA_SUBDIR=win-32
conda create --name py32 --clone python3.10
conda activate py32
conda update --all

# Then I tried to run auto-py-to-exe
auto-py-to-exe

After this, I did a transformation using auto-py-to-exe successfully. But still, I get this error on 32bit windows when I try to execute the .exe file:

Picture of the error

Now I'm somewhat disappointed about how I should achieve my goal.

Important Question: Why did I use set CONDA_SUBDIR=win-32? Because I think that command helps me clone everything with 32bit format and converts my cloned Python to a 32bit version, this helps me run auto-py-to-exe and convert my .py file to a .exe 32bit file. But it seems I'm wrong about this since I can't run the .exe file in 32bit OS.

Can you please help me how I can create a 32bit version of Python in a Conda environment and then use auto-py-to-exe to create the 32bit .exe file? (I assume that auto-py-to-exe also uses Python for running, and the 32bit version of Python influence on auto-py-to-exe result.)


Additional details:
My OS: 64bit Windows 10
But I want to run the .exe file on another machine that has 32bit Windows 10


Update:
Since I didn't get an answer about Conda environments, I tried installing 32bit Python. I achieved a 32bit .exe file with these steps:

  1. Installing Python 3.10.1 32bit using this link.
  2. Adding the Python path to the User variables and System variables: enter image description here enter image description here
  3. Then I opened cmd and installed the required packages like auto-py-to-exe (also those used in .py) using pip.
  4. run auto-py-to-exe in cmd and start converting.

The result is a 32bit .exe file that a 32bit OS can execute. But This isn't exactly what I looked for(it works, but it made me install a 32bit Python and add it to the path, which isn't what I looked for). So I write this here and hope for someone to help me do these in a Conda environment.

Shayan
  • 5,165
  • 4
  • 16
  • 45
  • Consider using other tools that are more modern and flexible, like cx_freeze or pyinstaller. Also, *conda environments are not really intended for such usage, and you should consider more standard situations: for a standalone application there is very little use of a similar type of environment, and standard usage will actually be much more flexible (and easier to debug). – musicamante Mar 07 '22 at 03:16
  • @musicamante I should mention that as stated in the [official GitHub of `auto-py-to-exe`](https://github.com/brentvollebregt/auto-py-to-exe), *"Auto PY to EXE, A .py to .exe converter using a simple graphical interface and PyInstaller in Python."* thanks for your advice. Can you explain more about *"standard usage"*? I'll check `cx_freeze` as well. – Shayan Mar 07 '22 at 15:24
  • Where is it written that you need a 32-bit environment? – musicamante Mar 08 '22 at 03:37
  • @musicamante I read about it on a website(I don't remember the address). Do you have a better idea? – Shayan Mar 08 '22 at 03:41
  • I don't see any reference of that requirement on the official github, so why don't you just try to use the default 64-bit system you probably already have? – musicamante Mar 08 '22 at 03:42
  • @musicamante Try to use it for what purpose exactly? Can you please make this clear? – Shayan Mar 08 '22 at 03:44
  • In the official `auto-py-to-exe` there is no reference that says that you need to use a 32-bit environment, so why don't you just use the current 64-bit one you are already using? – musicamante Mar 08 '22 at 03:46
  • @musicamante, isn't this obvious from my explains in the question? Because that gives me a 64bit executable file! But I'm looking for a 32bit one, not a 64bit! – Shayan Mar 08 '22 at 03:49
  • Ok, so I probably misunderstood your question, sorry for that. Now, if you **really** do need a 32-bit executable, well, that's not easy nowadays. This brings us back to the original point: if you just need a final executable, creating a full conda environment is completely pointless; you just need a basic 32-bit python environment, so, even if you may not like it, you have to stick with it. Besides: if you need a 32-bit environment, all executable-related 32-bit files will need to be installed; that is a basic requirement. – musicamante Mar 08 '22 at 03:52
  • @musicamante, do you know how to create an environment with 32-bit python? I'm so okay with the "environments" like virtual environments. What bothers me is to install a new 32-bit python and add it to the default PATH. – Shayan Mar 08 '22 at 03:57
  • As said, it's not that easy nowadays, as most situations will prevent that for various reasons. A possible alternative (somehow easier and less invasive) could be to install a virtual machine with an OS that still supports that architecture. I'm assuming you're using Windows, so I cannot really help you there, but I believe that there are still ways to install a not-so-old Windows version that still runs on 32-bit. What puzzles me is: why do you need a 32-bit executable? If you have a target 32-bit machine, can't you do the builds on *that* machine? – musicamante Mar 08 '22 at 04:01
  • @musicamante, Thanks! No, unfortunately, I can't. I tried to run the procedure on the 32-bit machine, but it was too slow and weak for that :))) it's a kind of HP Tablet PC. – Shayan Mar 08 '22 at 04:11
  • Then, a VM is probably the best choice. Consider that the 64-bit migration began lots of years ago, and there are modules and libraries that may not be available anymore. My suggestion is to take your time (*a lot of time*, be patient!), learn how to properly create a valid 32-bit Windows machine, possibly with the target OS, and then carefully read all the documentation about installing a valid environment. Note that you might need to be very careful in reading docs and tutorials: check their modification date, as they might not be valid anymore (because they're too old, or even too modern!). – musicamante Mar 08 '22 at 04:18
  • @musicamante Thank you for putting time into this. I appreciate it. Indeed I'll consider your advice. – Shayan Mar 08 '22 at 04:21

1 Answers1

1

Don't use Conda environment use venv or pipenv. you can't convert conda environment .py file to exe because of its dependency.While using venv use pyinstaller. install comand - pip install pyinstaller convert command - pyinstaller --onefile -w 'filename.py' When using pipenv use auto-py-to-exe. yeah auto-py-to-exe is old, but there are no other tools.as for conda you can't do anything.

Aniket M
  • 31
  • 5