(Python) PyInstaller unicode error - python

I'm trying to compile a webscraper that I'm working on to see if it will run properly on other systems. I'm using pyinstaller 3.0. Followed install instructions, installed prerequisites, no errors.
When I try to compile it using:
pyinstaller wowscrape.py
I get this unicode error:
...
File "C:\Users\brian_000\Documents\GitHubVisualStudio\wowscrape\wowscrape\wowscrape\wowscrape.py" line 1
\ufeffimport os
^
SyntaxError: invalid character in identifier
The only stuff I could find on unicode and pyinstaller had to do with installing it on linux.
I dug through the build folder and noticed that inside the "base_library" rar that there are handlers for unicode, so I'm not sure what it's getting hung up on.
I'm using Python 3.4, in this project I have:
os
sys
urllib
bs4
pyqt5
loginwindow << is an import from qt designer converted to python
mainwindow << is an import from qt designer converted to python
If there isn't a way to make this work with pyinstaller, are there any other options? I haven't seen much support for packing Python 3 into exe's with cross system support. Since it's a scraper based around WoW, I would like to have this produce applications for Win/Mac/Nix.
Thank you in advance.
Here is the main script I'm trying to build, if it will help.
I know, it's messy and long. It's still being prototyped.
link to code

Save your file in an editor encoded as UTF-8 without byte order mark (BOM) and try again. A decent editor should have a menu entry such as File --> Save with encoding.

Related

No module named 'pygame.base'

I've been having a lot of trouble converting one of my python projects into an executable with the use of pyinstaller. Upon launching the .exe, it gives this rather simple error that I just can't get my head around. The script works as intended in the editor (pycharm in this case).
In pyinstaller there is a single warning message displayed, "Hidden import "pygame._view" not found!"
I've tried using 32 and 64 bit versions of pygame, reinstalled several times and purged pip cache history.
I'm aware images aren't liked around here, but the .exe only remains open for one frame, I simply don't have enough time to copy the actual text.
Full error message
If the code works fine in pycharm, then it might just be an issue with importing the module in the script. At least that's what the error emssage seems to be saying. Do you specifically import pygame.base or the like in the __init__.py script?

Incompatibility pyinstaller and sklearn

I'm trying to create a .exe file com a .py file using auto-py-to-exe, that uses pyinstaller for creating the file.
The problem is, on codes that I import the sklearn lib, I get the following error on opening the output exe file:
enter image description here
I have already tried including hidden imports from sklearn, cx-freeze, sklearn.neighbors.typedefs','sklearn.neighbors.quad_tree','sklearn.tree._utils' and sklearn.utils._cython_blas.
Also tried one file and one directory, both with same problem.
Also tried directly using pyinstaller, with same error. It works fine on codes without sklearn. Tried on python versions 3.6, 3.7 and 3.8.
Does anyone have a glue on how to solve this problem?
Thank you.

Where can I find pre-installed packages that comes with Python IDLE?

I'm more specifically wanting to know whether sqlite3 and json comes with python IDLE or do I have to install them separately to use them inside IDLE, If so can anyone link me to those installing procedures of sqlite3 and json on Python IDLE?
I also want to know where I can find the list of other pre-installed packages that comes with basic Python IDLE (i.e. Python 2.7.14) . I am a Beginner and it would be really helpful.
Thank you.
To get a list of your packages, from your terminal, launch python :
python
Then
help("modules")
Another solution, if you want to check if json or sqlite3 are installed, start Python from your terminal :
python
Then import sqlite3 and json:
import json
import sqlite3
You can check theirs version with :
>>> json.__version__
'2.0.9'
>>> sqlite3.version
'2.6.0'
IDLE is part of the CPython standard library and is usually installed when tkinter (and turtle) are. It provides an optional alternate interface for running your code with a particular python binary. When you run code through IDLE, it is run by the python binary that is running IDLE. So the same modules are available whether you run code through the terminal interface or through IDLE. There is no separate installation.

syntax error during py2app build

New to programming (so please bear with me), but loving it so far. I coded a game using pygame and am having trouble compiling it as a stand-alone application using py2app. I'm using Macports Python 2.7, though I tried switching back to the default Mac installation (2.7) as well as the default 2.6 and still get this error during the py2app build:
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sympy/mpmath/libmp/exec_py3.py", line 1
exec_ = exec
^
SyntaxError: invalid syntax
Exec_py3.py consists of all of one line:
exec_ = exec
Just for laughs I commented it out and the py2app proceeded further along in the build but then choked here:
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/macholib/MachO.py", line 304, in synchronize_size
raise ValueError("New Mach-O header is too large to relocate")
ValueError: New Mach-O header is too large to relocate
I don't know if the issues are related. Py2app is working fine for a couple little test scripts I wrote that don't use pygame. Any suggestions for what I can try next?
Thanks!
edit - I found a couple of links that may be related, but can't really understand what's going on in the conversation. Can anyone translate for a relative newby?
http://code.google.com/p/mpmath/issues/detail?id=204
https://bitbucket.org/ronaldoussoren/py2app/issue/93/mach-o-header-may-be-too-large-to-relocate
Well, I found a workaround in case anybody else runs into this. I uninstalled MacPorts and just used the Mac system Python (2.7). Everything then compiled fine. It was not enough just to use the port select command to switch to the system Python; I had to deinstall the whole thing.

How can I use xml.sax module on an executable made with PyInstaller?

I want to have my application read a document using xml.sax.parse. Things work fine but when I move the executable to a Windows server 2008 machine things break down. I get an SAXReaderNotAvailable exception with "No parsers found" message.
The setup I'm using to build the executable is:
64 bit windows 7
Python 2.7.2 32-bit
PyInstaller 1.5.1
SAX readers seems to be dynamically imported, so the static analysis can't detect them and they can't be embedded with application.
To correct this, you'll have to be explicit to force PyInstaller to import those hidden modules.
Try to add this to you .spec (thanks Velociraptors) file :
hiddenimports = ['xml.sax.drivers', 'xml.sax.drivers2']
The executable turned out to be fine. For some reason or the other there's wrong versions of the needed dlls in PATH and the executable ended up trying to use those.

Categories

Resources