PyInstaller on cygwin - python

I need to create an .exe file from a .py file on cygwin. Since py2exe doesn't seem to work there, I tried PyInstaller. However I have a problem installing it. pip install pyinstaller returns this message:
ERROR: Failed compiling the bootloader. Please compile manually and rerun setup.py
So I tried to follow this guide: https://pyinstaller.readthedocs.io/en/latest/bootloader-building.html and install it manually. But when I run pip install https://github.com/pyinstaller/pyinstaller/archive/develop.tar.gz the folder that I get for PyInstaller is not https://github.com/pyinstaller/pyinstaller but this one: https://github.com/pyinstaller/pyinstaller/tree/develop/PyInstaller in which there are no waf files and I can't run python ./waf all.
So I downloaded the needed folder from github manually and then python ./waf all succeded. However, I still can't not use PyInstaller since I get this error when trying to call it from command line:
ModuleNotFoundError: No module named 'PyInstaller.__main__'
And I have no clue how to fix it. What should I do to get PyInstaller working or maybe I need to to use some other module that works with cygwin?

Related

How do I make exe file with torch module by using pyinstaller?

[Environment]
vscode
Anaconda
Window
I successfully ran main_for_exe.py in vscode.
When I make exe file using pyinstaller and then ran exe file, however, I have the below error message.
enter image description here
There were some solutions: "add module to hiddenimports"
enter image description here
but, it does not work.
Basic modules of python such as "os" and "sys" are successfully loaded, but "No module named numpy" error message appeared. So, I think that modules installed by 'pip' and 'conda' aren't loaded.
How do I solve this?
No matter base or other virtual conda environments, we need to first activate it then with the command pip install executed in integrated Terminal, the module can get its right location, or it will throw No module error.
Now open your project in VS Code, after activating anaconda environment, run pip show numpy to check if its location is anaconda\lib\site-packages. If not, please reinstall it, then regenerate .exe, the error should go away.
Reference: Select and activate Environment.
I solved this problem!
I just upgraded the pyinstaller package.
It seems that the pyinstaller package, before upgrade, cannot find the site-package path where the modules installed by anaconda are located.
(Generally site-packe path: "~/anaconda3/lib/site-packages")
In this case, there are two solutions.
First, you just upgrade pyinstaller.
Second, you add site-package path to hookspath and then run "pyinstaller main.spec".

pyinstaller downloaded using pip not working after installation

Screenshot of error
I'm trying to install a module called pyinstaller from pip to make .py files into an executable, but can't run it from command prompt. Any ideas as to why it doesn't work or workarounds with other applications that serve the same purpose?
try changing directory to where python location is and try installing again
i.e C:\Users--------------------\AppData\Local\Programs\Python\Python39> pip install pyinstaller

How to make pyinstaller not use anaconda and build a small-size exe file

I have been trying to build .exe file using pyinstaller in windows 10. It worked, but the size of the exe file is ~212 MB, even by using a venv (as in here). I thought it might be because I am using python by anaconda!
Then I installed a separate version of Python so not to use anaconda! But it did not work (still large file).
Then I uninstalled anaconda to test it. Pyinstaller is still trying to access Python in 'C:\Program Files\anaconda3\python.exe' (this error: No Python at 'C:\Program Files\anaconda3\python.exe'). However I have removed all path to anaconda. Probably it has always tried to reach anaconda, and this is why I haven't been successful to build a small size .exe file.
How can I clearly indicate paths for pyinstaller and python?
Finally, after a lot of researching, could solve my problem:
Uninstalled all pythons and anaconda from my PC
Removed all Path from the system variables
Restarted the windows
Installed a fresh Python from its website
Installed Pyinstaller using pip install pyinstaller
Tested my .py code in cmd. It showed me all the packages that are missing.
Installed all required packages by using pip install name-of-package
Ran final command by pyinstaller -F -w --clean file.py
(Optional) Install Anaconda if you need (don't add Anaconda Python as the default python. Also don't add its path to the system variables).
Note: You can build virtualenv and do pyinstaller in them.
My previous tries which used anaconda resulted in file of 212 MB in size. This process generated a .exe file of size 27 MB (Importing only pandas module).
I ran into a similar problem and found PyCharms virtualenv manager very helpful. https://www.jetbrains.com/help/pycharm/creating-virtual-environment.html
This just necessitated downloading python from python.org and linking the virtual environment to this interpreter, rather than the conda interpreter (otherwise it will throw strange SSL errors).
This seems to allow neat parallel use of conda and virtualenv.

Pyinstaller command not found (MacOS)

I've been trying to use PyInstaller on my program, scratch_1.py. The PyCharm project folder is called "idigen", which is saved in my desktop. So, I changed the director like so:
cd /Users/joelsaarinen/Desktop/idigen
then, moved on to use pyinstaller, and I get this error:
pyinstaller scratch_1.py
-bash: pyinstaller: command not found
I'm confused because when I use:
pip show pyinstaller
to verify that I have pyinstaller installed, it returns a positive result.
Is there an additional command I should be putting in when using Pyinstaller on one of my files? Might this be an issue with this specific program or the operating system in general? Thanks in advance.
This is a common problem due to the fact that you might install a different version of python and keep using an old version that is preinstalled in the machine. Here is the best solution.
First, check the version of the python that you installed. In my case, i installed python 3.5 and the machine had python2.7. If you run python on the terminal, most likely the preinstalled one is the one that will run.
Second, check the directory of your desired python version. watch -a python3 is the command to run to see your directory.
Third, set the directory as the main one to run your python commands.
alias python=/usr/local/bin/python3 does the whole trick
Lastly, reinstall pip. Download the get-pip.py file and run sudo /usr/local/bin/python3 get-pip.py * I used the path to show the reason we updated the alias*
Now you can run pyinstaller without problems
pyinstaller appears to have installed correctly, but the command is not available on PATH. You need to locate where the executable was placed.`below to find executables
set | grep pyinstaller
now modify path by this
export PATH=some_path:another_path
launchctl setenv PATH $PATH
I just downloaded the source code of pyInstaller from official website, put it where I can find it and wrote a script which launches pyinstaller.py from that folder.
For some reason, pyinstaller.py is missing in the pyInstaller installation downloaded via pip.
I had the same issue on MacOS with Developer Tools 11.4 and found two ways to start pyinstaller:
alt 1: path based solution
$ pip3 show -f pyinstaller|grep pyinstaller
will find pyinstaller in a bin path:
../../../../usr/local/bin/pyinstaller
...
So you can use one of the set-the-path-or-an-alias approaches or call via fully qualified path.
alt 2: call via python module
$ pip3 show -f pyinstaller|grep __init__
will get you a hint on how pyinstaller is defined as a module:
PyInstaller/__init__.py
...
With that capitalization, it's possible to call pyinstaller as a module with the following:
$ python3 -m PyInstaller --version
4.2
I'm using the latter now.

pipenv and pyinstaller not packaging dependencies

I'm fairly new to python I'm trying to create an executable of my python project that is run in pipenv. However, when I try and compile and run the code using pyinstaller it can't find any dependencies since they aren't installed globally. I don't want to install them globally, this is supposed to be a deployable build that shouldn't require any setup beyond just the exe.
Am I missing something? Is this even the right way to go?
I can run the project easily like so:
pipenv run python iot.py
It has a dependency:
from AWSIoTPythonSDK.MQTTLib import AWSIoTMQTTClient
And I try and compile the project like so:
pipenv run pyinstaller --onefile iot.py
It creates an executable that fails to find imported modules.
Traceback (most recent call last):
File "iot.py", line 18, in <module>
ImportError: No module named AWSIoTPythonSDK.MQTTLib
[48823] Failed to execute script iot
Am I just so off in my attempt or is there just a simple missing link?
Thanks for any help.
This is because you installed pyinstaller globally.
Use pipenv install -d pyinstaller before packing.
I found that pyinstaller won't package dependencies inside the pipenv.
If I install the dependencies globally I can ship the exe.
For now, I'll make a build machine that handles downloading dependencies and building the exe.
You can tell pyinstaller to look in the virtual env created by pipenv when searching for the required modules.
$ pipenv --venv
path\to\.virtualenvs\project
$ pipenv run pyinstaller --paths path\to\.virtualenvs\project project.py

Categories

Resources