Creating an executable from python file - python-3.x

I need to make an executable out of a .py file. I looked into it and tried:
py2exe -> this doesn't work with python3.8 (gives me "IndexError: tuple index out of range")
pyinstaller -> still doesn't work (TypeError: an integer is required (got type bytes))
For pyinstaller I might have found a solution here but still doesn't work for me. (a user said to use the latest version compatible with 3.8 -> pip install https://github.com/pyinstaller/pyinstaller/archive/develop.tar.gz
Any alternative solution / fix would be greatly appreciated

This subject has been discussed here
The latest release of Py2exe (0.9.2.2) was built for Python 3.4 and will not work in 3.7+.
There is a Github project that is porting Py2exe to 3.7 (link here). I made some tests with Python 3.7 and it works well to generate exe files.

Related

Attribute error : module "pytest" has no attribute "hookimpl"

I have installed python 3.8.3 in windows 8/64 bit.. I need to start with pytest...path has been set properly... In Pycharm I am getting
Attribute error : module "pytest" has no attribute "hookimpl"
All the plugins installed as per the latest version
Pytest doesn't supports Python 3.8 yet.
Supported versions for Pytest
Python 3.5
Python 3.6
Python 3.7
PyPy3
Create a new virtualenv in Pycharm with these versions. If you don't know how here is a link for you.
Pycharm Configuring Python Interpreter
Also if you are interested you can find more info about Pytest Installation
There appears to be an issue with a Magic String here. Make sure you dont have any file named identically to any internal python code. I changed my package name from 'pytest' to 'pytestdemo' and this error was resolved.
Check your pytest project/package name, it should not start with 'Test'. I got same issue when project/package name was "Test". Changing the project/package name solved the issue.

Pandas install or import in IBM SPSS Statistics Version 26

I have installed the latest version of IBM SPSS Statistics(Version 26) which has pre installed python 3.4 and 2.7. i am trying to use version 3.4 python. i am able to import modules like pip , sys , os etc. i tried pandas the same way. i am unable to do so. getting error no module found. Hence going through our forum and IBM support did the following changes.
received the following error
1) tried pointing the site-packages via
import sys
# Assuming windows and standard python folder here.
sys.path.append(r"D:\Python34\Lib\site-packages")
2) changed the path in the settings of SPSS
3) Tried installing pip in the below folder as suggested in the forum but got message i have already installed the updated version.
C:\Program Files\IBM\SPSS\Statistics\Subscription\Python3
4) following versions of python were installed
have tried what i could. Need your expertise help to fix the same which will help me to install/use modules needed for SPSS. Thanks.
This is going to be painful to explain, I'll do my best.
As far as I can tell, you're on windows. Usually when we need a new package, we just open cmd and type pip install xxx (assume you added python to path when installing it). The reason that this works, is because when you type pip install xxx in cmd, windows recognize pip to be a command because python path is in system variables. Windows know that I can execute pip install with this python path.
However for SPSS python (3.4), that python had a different path in the system. Thus when you only have the 3.7 or 3.8 python in path, windows cannot install package to you 3.4 python, and I'm not sure if you can have more than one python path in system.
In order to fix this, you need to first figure out what's the path to your 3.4 python, then in this page you can follow the instruction to remove your 3.7 or 3.8 python in path, and add your 3.4 path, then you can do pip install xxxx for whatever package you want
I did the same thing with a arcgis python distribution, hope this works for you. If the attached page does not work, just google add python path to windows and look for a instruction that works on you PC
Oh and the reason that you can import pip, sys and some other package but not pandas, is because python is 'battery included', it comes with tons of packages pre-installed for additional functionality, but pandas is not one of them.
Fixed it since my ananconda had version 3.7 .i created virtual environment and installed 2.7 python with anaconda package. Pointed SPSS to the 2.7 folder and was able to import pandas.

Python packaging with Pyinstaller

I am trying to package my python file using Pyinstaller. I follow the instructions from this link
https://datatofish.com/executable-pyinstaller/
but I get this error.
RecursionError: maximum recursion depth exceeded.
I tried to added the following line of code as it was suggested on few pages but so far no success.
**import sys
sys.setrecursionlimit(1500).**
Any help?
Just so you all know the error was caused by Anaconda environment. It is not compatible with Python 3.7 and Pyinstaller. As soon I as uninstall Anaconda and run the Pyinstaller function, everything was fine and I managed to create an exe file.

fbs freeze failed with Python 3.6.4

I have the following problem with fbs and Python: I tried to compile Python code and wanted to create an executable .exe file in windows. The command fbs run works fine, but fbs freeze fails.
Package versions:
Python 3.6.4
PyInstaller: 3.4
PyQt5: 5.9.2
Packages that I import:
import re
from itertools import chain
import os
import pandas
from PyQt5.QtWidgets import *
from fbs_runtime.application_context.PyQt5 import ApplicationContext
The output of fbs freeze --debug you see in the attached image:
I used the pyinstaller command to create the exe. This was possible without fbs. Just pyinstaller with the standard comments pyinstaller "...." --onefile --noconsole.
It worked with Python 3.6.4 and pyinstaller 3.4. Perhaps 3.5 would also work. But I know at least that Python 3.8.0 with the newest pyinstaller (even development version from git) doesn't work. I used PyQt5, but some older version 5.12....
It's a bit intransparent...
Best regards,
Markus
fbs runs perfectly fine with python 3.6.x (I am using 3.6.8, PyQt 5.9.2, PyInstaller 3.4).
The python compiler can sometimes get confused if another error happens earlier in the stack. Generally if fbs freeze errors when fbs run works, that points to a library-include error.
See my answer here to include necessary python library resources in your ./src/freeze/windows/ directory and try freezing again: The 'google-api-python-client' distribution was not found and is required by the application with pyinstaller

How do I set the path variables for coexistence of Python 2.7, Python 3.x and Anaconda

Having several exe's of Python, I would like to specify the command (py or python) to launch a certain version from the command line.
At the moment, I have different versions of Python (2.7, 3.6, 3.7 Anaconda) installed on my Windows machines (7 at work, 10 at home). Unfortunately, the commands in the cmd-prompt are not the same.
The output of the following cmd commands is as follows:
py -> 3.7.1 of Anaconda (work) and 3.7.0 (home)
python -> 2.7.13 (work) and 3.6.2 (home)
pyton2 -> not recognized (work) and 2.7.15 (home)
How can I order the variables, so the same commands call the same version of python? Researching about the path variable I could not find how to define the command that launches a specific python.exe.
I really appreciate your help or a pointing in the right direction.
Kind regards,
Seb
Good Morning,
my apologies, yesterday I did not find this thread here:
In CMD "python" starts Python 3.3, "py" starts Python 2.7, how do I change this?
From now on I will go with "py -X.Y" to start the version of Python I want.
Kind regards,
Seb

Resources