>>> s = "C:\Users\sym\Desktop\check\pyinstaller_check.py"
Traceback (most recent call last):
File "C:\Python36\lib\code.py", line 63, in runsource
code = self.compile(source, filename, symbol)
File "C:\Python36\lib\codeop.py", line 168, in __call__
return _maybe_compile(self.compiler, source, filename, symbol)
File "C:\Python36\lib\codeop.py", line 99, in _maybe_compile
raise err1
File "C:\Python36\lib\codeop.py", line 87, in _maybe_compile
code1 = compiler(source + "\n", filename, symbol)
File "C:\Python36\lib\codeop.py", line 133, in __call__
codeob = compile(source, filename, symbol, self.flags, 1)
File "<interactive input>", line 1
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
You can not use
C:\U
in python 3.
Turn all backslash the other way,as you should always do or double up
\\
.
>>> s = "C:/Users/sym/Desktop/check/pyinstaller_check.py"
>>> s
'C:/Users/sym/Desktop/check/pyinstaller_check.py'
Here a run with pyinstaller and the code you have postet.
I use virtual environment which now is build into Python 3.5 -->.
Virtual environment is great for not messing with OS installed Python versions.
Here the run from start to
hello.exe
.
I use
cmder,but is't just the same in cmd.
# Make virtual enviroment
C:\Python35
λ python -m venv pyinstaller_test
C:\Python35
λ cd pyinstaller_test
# Activate virtual environment
C:\Python35\pyinstaller_test
λ C:\Python35\pyinstaller_test\Scripts\activate.bat
(pyinstaller_test) C:\Python35\pyinstaller_test
# Check that pip from virtual environment is used
(pyinstaller_test) C:\Python35\pyinstaller_test
λ pip -V
pip 8.1.1 from c:\python35\pyinstaller_test\lib\site-packages (python 3.5)
# Install pyinstaller
(pyinstaller_test) C:\Python35\pyinstaller_test
λ pip install pyinstaller
Collecting pyinstaller
Using cached PyInstaller-3.2.1.tar.bz2
Requirement already satisfied (use --upgrade to upgrade): setuptools in c:\python35\pyinstaller_test\lib\site-p
ackages (from pyinstaller)
Collecting future (from pyinstaller)
Using cached future-0.16.0.tar.gz
Collecting pypiwin32 (from pyinstaller)
Downloading pypiwin32-219-cp35-none-win32.whl (7.9MB)
100% |################################| 7.9MB 156kB/s
Installing collected packages: future, pypiwin32, pyinstaller
Running setup.py install for future ... done
Running setup.py install for pyinstaller ... done
Successfully installed future-0.16.0 pyinstaller-3.2.1 pypiwin32-219
# Make exe
(pyinstaller_test) C:\Python35\pyinstaller_test
λ pyinstaller hello.py
A lot of install stuff...........
8040 INFO: Building COLLECT out00-COLLECT.toc completed successfully.
(pyinstaller_test) C:\Python35\pyinstaller_test
λ cd dist
(pyinstaller_test) C:\Python35\pyinstaller_test\dist
λ cd hello
# Test exe
(pyinstaller_test) C:\Python35\pyinstaller_test\dist\hello
λ hello.exe
Hello World