I am trying to create an exe from python script using cx_freeze
I have been able to create the build and test it successfully on win7 but whenever I try to run the exe on win xp I get the following error.
Have tried uninstalling and reinstalling cx_freeze but it wont help.
I am using python 3.4
AttributeError: function 'SetProcessDPIAware' not found
Complete error description
Got the solution.
Build the application on win xp pc.
Add the following lines to your setup file-
os.environ["TCL_LIBRARY"]=r"C:\Python34\tcl\tcl8.6"
os.environ["TCLLIBPATH"]=r"C:\Python34\tcl\tcl8.6"
os.environ["TK_LIBRARY"]=r"C:\Python34\tcl\tk8.6"
All must point to the correct tcl paths within the python setup.
In my case it was looking for tcl in some other location due to some environment variable confusion.
And build your script using cx_freeze again.
Will work like a charm.
Related
I wrote a python program that uses the library tkVideoPlayer (and others). The python script runs fine without any errors but when I use pyinstaller to convert it into an exe, the exe doesn't run at all and I get the following error. (see image)
Things I have tried already:
Locating the file and moving it to the folder my exe is in.
Using a star import for the library
Using the --hidden option when creating the exe and specifying av/av.libs
Issue occurred due to me using Anaconda 3 (Sypder). It was using a virtual Environment and pyinstaller failed to locate the library correctly.
Solution: Installed python 3 directly onto windows, then installed pyinstaller and and all the libraries I used. Since that isn't a virtual environment it worked fine and the exe ran perfectly.
I've created a script using selenium and chromedriver on pycharm that works absolutely fine. I want to create an exe of that script so that I can run it on other PCs without installing python or the other dependencies. I've tried using pyinstaller but it is not working. Can someone guide me how can I convert that script into exe.
Thanks!!!
You are getting any error ? as pyinstaller is the best option to turn your script in to executables.
I want to debug an application using Python and Flask in VSCode. I have installed Flask and the app runs perfectly fine through cmd. But, when I try to debug it through VSCode, it gives the following error:
cd 'c:\Users\Aditi\CleanHandymanApp';
${env:FLASK_APP}='NewApp'; ${env:PYTHONIOENCODING}='UTF-8';
${env:PYTHONUNBUFFERED}='1'; & 'C:\Users\Aditi\envs\CleanHandymanApp\Scripts\python.exe'
'c:\Users\Aditi\.vscode\extensions\ms-python.python-2018.10.1\pythonFiles\experimental\ptvsd_launcher.py' '--client' '--host'
'localhost' '--port' '63143' '-m' 'flask' 'run' '--no-debugger' '--no-reload'
No module named flask
Can you please help me.
This error message can occur if you installed the python3 version of flask but Visual Studio Code tries to run your project with python2.
Make sure to select the correct version of python in the editor. This can be done by running the command Python: Select Interpreter from the Command Palette (Ctrl+Shift+P).
Activate your virtualenv and run
pip3 install -r requirements.txt
to reinstall all packages inside the venv.
For some reason VS Code thought I was missing all my packages the first time I debugged even though the app was running fine locally.
Sometimes you can get this error if you loaded Flask into a folder which has sub-files. For instance, if you loaded flask into the parent folder with the virtual shell instance but you're running your code in the child file (let's say parent is called crypto_files and inside that is a python source code file called blockchain.py ), then in order to get flask to run properly you'd have to run the file like this:
python crypto_files/blockchain.py
This allows your machine to see Flask running inside crypto_files but also run blockchain.py .
OR, it's possibly you could just reload Flask into the sub(child)file... blockchain.py and then you'd run it from within the subfile.
This complication is mainly due to modern "virtual instances" and shells which are basically like creating a virtual computer-machine inside your ACTUAL hard machine. Flask does this to avoid running everywhere, and since Flask is modular it allows each of your projects to run different modular configurations of Flask to suit each project precisely. The alternative would be awful: you'd have to load the fattest version of Flask with dozens of add-ons for each project, and so all your git and all your projects would have tons of extra code. Flask is built to be very small at the core to avoid this problem (too verbose!).
If you have installed flask in virtual environment, you should have activated it first.
source /path to env dir/bin/activate #in linux
workon 'name of env' #windows
Another option is add sys.path.append('d:/programas/anaconda3/lib/site-packages') in c:\Users\Aditi.vscode\extensions\ms-python.python-2018.10.1\pythonFiles\experimental\ptvsd_launcher.py
Being that "d:/programas/anaconda3/lib/site-packages" should be modified by your local python packages.
Use this command in the terminal instead of selecting run code:
python3 "insert your file name here without the quotes"
e.g.: python3 example.py
I had a variant of the issue mentioned by #confusius. I had installed both Python 3.9 and Python 3.10. I had added Flask to Python 3.10. I had been using one vscode workspace which had selected Python 3.10. I started another project in a different vscode workspace and it had selected Python 3.9 by default, which I didn't notice because I thought it would select the same Python I had already selected in the other workspace.
After dealing with all .egg issues with cx_freeze, I'm having issues running the .exe on click or from .bat. If I run the .exe from cmd, it runs perfectly. But if I click on the .exe, I get a popup list of errors that goes off the page.
I've tried changing the base=None and base=Win32GUI to no avail.
I'm running python 3.4 from and Anaconda environment. The errors make it look like on running, the .exe is looking in the normal python path, but there are references the the correct python path as well.
Any experiences with this?
Error from clicking. This goes off the screen so I can't see the final error:
error
Ok, I am using python 3.4.3 and I think I downloaded the right file but when I go to python shell, it says No module named 'cx_Freeze'
I know there are plenty of questions like this but none of them helped. There was one I found using my exact same problem and version but even that did not work. I do not know what to do. I have put the file in the same place, I think anyways, as python is and I tried putting it on my desktop but still does not work. Any ideas?
faced a similar problem (Python 3.4 32-bit, on Windows 7 64-bit). After installation of cx_freeze, three files appeared in c:\Python34\Scripts:
cxfreeze
cxfreeze-postinstall
cxfreeze-quickstart
These files have no file extensions, but appear to be Python scripts. When you run python.exe cxfreeze-postinstall from the command prompt, two batch files are being created in the Python scripts directory:
cxfreeze.bat
cxfreeze-quickstart.bat
From that moment on, you should be able to run cx_freeze.
cx_freeze was installed using the provided win32 installer (cx_Freeze-4.3.3.win32-py3.4.exe). Installing it using pip gave exactly the same result.
Ok, I figured it out. So this is for all the future people have the same problem as I am. First, download pip. Then open a python shell and import pip. This is to make sure the download of pip was successful. Then go to the cx_Freeze website and for python 3.4.3, it will be the last one I think. It will say the version of cx_Freeze and then say the version of python which is 3.4.3 for me. That will download and then go to python shell and import cx_Freeze. It should work. Remember that you have to capitalize the "F" and have the code be exactly like this "cx_Freeze" but without the quotes. That is how I solved this problem with this exact python version.