I am using python 3.6 and nothing is working for me. I just can't install any of the tools for creating an executable. I tried cx_freeze, using pip had Visual C++ errors which I fixed and then it had more errors so I downloaded a wheel and that installed and in my Scripts folder there are three cxfreeze related files, none of which are batch files and when I run 'cxfreeze' in cmd it just says it is not recognised. For some reason python is installed in appdata/local/programs... but that is set in my path so I cannot see how that doesn't work. I tried pyinstaller with both pip and the download and nothing but errors about pypiwin32 which I can't get because of some other errors.
I do not know what is happening and I do not know what to do about all of this. Can someone just help me get a tool working to create an executable please. Is this because I am using python 3.6?
Try py2app (if you are on a mac) or py2exe (if you are on a windows). The setup is relatively easy.
https://pythonhosted.org/py2app/
http://www.py2exe.org/
Related
I have already converted my python script .py to .exe using pyinstaller. When I try to run this exe in Windows 10. It states this app can not be run on your PC.
As far as I see, I need to install Python in Windows as well, but in my situation this is not an option. In my company, every computer uses Windows 10 and there is no way for me to install Python all of them.
What I wonder is that whether there is any way to run my .py script in Windows 10 without installing anything into Windows 10. I should give a working directory to people in my company and they should run my script with just one click.
EDIT:
With the help of #Amey and #L00n3y, I managed to solve my problem. In case anyone has same problem, I explained the procedure clearly, in this link.
have you tried py2exe?
py2exe is a distutils extension which allows to build standalone Windows executable programs from Python scripts.
You can download it here:
https://pypi.org/project/py2exe/
You can also use 'Pyinstaller' which is widely used.
Install it using,
pip install pyinstaller
And create an executable using the following command,
Python pyinstaller.py --onefile pythonfile.py
With the help of #Amey and #L00n3y, I managed to solve my problem. In case anyone has same problem, I explained the procedure clearly, in this link.
I made my second program in Python. It's a program that calculates the roots of a quadratic equation. I think it's cool and I want to let my friends use it without having to let them install python.
I heard about Pyinstaller from a friend and I tried this method out: first I typed pip install pyinstaller in cmd. Then I changed directory to the folder that contains the file that I want to share with my friends (it's called vkv.py). Then I entered this command: pyinstaller vkv.py but I got this error: Indexerror: tuple index out of range. Apparently the problem was that I have Python 3.6.0 and Pyinstaller only works with versions up to Python 3.5.
So I had to try another method. Yesterday, I tried cx_Freeze and some other method that I forgot, but both of them failed. Cx_Freeze failed due to me having Python 3.6.0 (same as Pyinstaller) and I don't remember what went wrong with the other method.
My friend (who told me about Pyinstaller) told me to use virtualenv, so I looked up a tutorial on the matter. Looks like I needed to make a virtual environment where I use Python 3.5. So these are the commands that I typed in cmd:
pip install virtualenv
mkdir Environments
cd environments
virtualenv -p C:\Users\hp\AppData\Local\Programs\Python\Python35\python.exe py35_env (before entering this command, I installed Python 3.5.0)
C:\Users\hp\Environments\py35_env\Scripts\activate
Now that the environment has been made and activated, I installed Pyinstaller in this environment, with pip install pyinstaller. Then I changed directory to: C:\Users\hp\Desktop\Code\Python testing (which is where the vkv.py file is located at). Then I typed: pyinstaller vkv.py, but now I got a whole bunch of lines, with an error on the last line: ImportError: DLL load failed: %1 is not a valid Win32 application.. Here is a screenshot of it:
Being the curious person that I am, I wanted to know what would happen if I opened another cmd window and tried Pyinstaller again without the environment (so I basically tried the very first method again, listed above). It is strange that I got the same "ImportError" and not the "IndexError" from before.
So now my questions are (ranked from more important to less important):
what can I do to let my friends run the Python file without having to install Python?
What does this ImportError mean and how can I fix it?
What happened there with the last time that I tried pyinstaller vkv.py in cmd outside of the environment? Why did it give me an ImportError and not the IndexError, which is what I got when I first tried to run this command?
Sorry to make this a long post, but I like to give a lot of information because I'm afraid that I might leave something important out.
Thanks in advance for any kind of help!
As you want to use Python 3.6, you can't use Pyinstaller, py2exe, cx_Freeze or others. However, there is a tool called Transcrypt and it's compatible with Python 3.6. It can be installed with pip: pip install transcrypt, and converts Python code into JavaScript. To use it open the console and type transcrypt vkv.py.
It automatically generates a folder, __javascript__, and files on it. When transcript ends, you are ready to use it with html.
(Assuming the .html is in the same directory as the .py and the folder)
<html>
<head>
<title>Example</title>
</head>
<body>
<script src="./__javascript__/vkv.min.js"></script>
</body>
</html>
You can use the html as an executable (depending on your program, here is the documentation) by running it with your browser.
Try removing 3.6 and installing 3.5.3 from python.org.
Retry with Pyinstaller.
Try using py2exe, it's a python module.
Its really simple all you need to do is:
Download and install it http://sourceforge.net/projects/py2exe/files/
Create your setup.py
Run your setup.py
Here's a site that will explain it more in detail http://inventwithpython.com/appendixc.html
I am able to use pyinstaller in my Python 3.6 environment. You need to download the zip file for Development Release (unstable) and instead of using pip, run the setup.py file from downloaded pyinstaller code.
I am wanting to compile all of my python scripts into one exe. I use the Vizard shell to find errors in my scripts. When I download the 64-bit install for py2exe (Python 2.7), and try to install it, the exe ignores my Python 2.7 directory, and chooses Vizard as the main directory. I uninstalled Vizard, rebooted my computer and tried the installation again, but to my surprise, it still had the Vizard directory as my main directory.
When I tried to install a 32-bit version, it located my Python directory just fine. However, the 32-bit version will not work and gives me ridiculous amounts of errors trying to run it.
Vizard is rather important to me, so I'd love to keep the program. Is there a way to install the 64-bit version outside of an exe? Thanks for the help.
I have a Python script I developed within a virtualenv on Windows (Python 2.7).
I would now like to compile it into a single EXE using Py2exe.
I've read and read the docs and stackoverflow, and yet I can't find a simple answer: How do I do this? I tried just installing py2exe (via the downloadable installer), but of course that doesn't work because it uses the system-level python, which doesn't have the dependencies for my script installed. It needs to use the virtualenv - but there doesn't seem to be such an option.
I did manage to get bbfreeze to work, but it outputs a dist folder crammed with files, and I just want a simple EXE file (one file) for my simple script, and I understand Py2Exe can do this.
tl;dr: How do I run Py2Exe within the context of a virtualenv so it correctly imports dependencies?
You can do that this way:
Activate your virtualenv and then ...
easy_install py2exe-0.6.9.win32-py2.7.exe
Installing py2exe into your virtual env should be straightforward. You'll need Visual Studio 2008, the express version should work. Launch a 2008 Command Prompt and Activate your virtual env. Change into the directory that contains the py2exe source and run python setup.py install. You can verify that py2exe is in the correct environment by attempting to import it from an interactive shell. I tested myself earlier today (had to install virtualenv). It works exactly as expected.
I have a problem with the following command:
setup.py install.
I know it should work, I have tried it on a laptop but I don't have access to it at the moment. I need to complete a homework so I tried the same on my PC. And when I type the same command into cmd it just runs pyscripter as if I would use right click on setup.py and click edit with pyscripter. It does nothing else. I am sure that I am in the right folder in cmd.
My python version is 2.7 and my pyscripter version is v2.5.3. My OS is win7. I have tried to install other modules but I get the same response.
Has anyone encountered the same problem? I have searched the internet but I haven't found any answers to this problem.
Assuming that you installed Python 2.7 in the default folder i.e. c:\python27, then you can type:
c:\python27\python setup.py install
Wherever you installed it, you should append that path to your PATH variable (you'll need to log on as an admin to do that).
Do python setup.py install instead.
Windows is probably not set up to recognize .py files as executable.
Recently our class at school used all of the above programs. about a handful of students had trouble installing like you described. Fortunally I didnt not have this problen but I can suggest you use Administration priviledges.
Make sure you download the correct version.
Go to your download folder and look at the file you have downloaded (do this via my computer not from your web browser)
Right click on the file and then click run as an administrator
Here is an awesome site for windows binaries: http://www.lfd.uci.edu/~gohlke/pythonlibs/
If the library you need is there, just download and install like any other windows program...