Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pip creates scripts for PyInstaller with no encoding specified #5539

Closed
me21 opened this issue Jun 26, 2018 · 7 comments
Closed

Pip creates scripts for PyInstaller with no encoding specified #5539

me21 opened this issue Jun 26, 2018 · 7 comments
Labels
auto-locked Outdated issues that have been locked by automation

Comments

@me21
Copy link

me21 commented Jun 26, 2018

First of all, I've already opened an issue in PyInstaller repo, but I was told this is not their issue but yours (or setuptools's).

Environment

  • pip version: 10.0.1
  • Python version: 3.6.5
  • OS: Windows 10 LTSB 2016 Russian

Description
I install PyInstaller with pip install pyinstaller. It installs, but doesn't work: pyinstaller myscript.py fails due to pyinstaller-script.py in the Scripts subfolder contains non-UTF-8 codes. In fact, its encoding is CP1251 on my machine but no encoding is specified inside the file.
The offending line contains the path to the Python interpreter executable. This is because I run all commands in the virtual environment located in path with non-latin characters. If I run commands in virtual environment placed in latin-only path, no errors are thrown.

Expected behavior

PyInstaller should work and create an executable file from my Python script.

How to Reproduce

  1. Create a virtual environment in the path which contains non-latin characters. And activate it.
  2. Run pip install pyinstaller.
  3. Create arbitrary Python script (we will try to create an executable from it).
  4. Run pyinstaller <script name>.py.
  5. An error occurs.

Output

File "C:\Users\Зарубкин\Documents\Python Projects\uno-db\venv\Scripts\pyinstaller-script.py", line 1
SyntaxError: Non-UTF-8 code starting with '\xc7' in file C:\Users\Зарубкин\Documents\Python Projects\uno-db\venv\Scripts\pyinstaller-script.py on line 1, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
@pfmoore
Copy link
Member

pfmoore commented Jun 26, 2018

If there's a pyinstaller-script.py file in the Scripts folder, then it's not pip creating the wrappers. Pip creates command line wrappers from the entry point metadata in the package, but it creates single file exe wrappers which don't use a -script.py support file.

If you're getting the -script.py file, the wrapper is probably being generated by setuptools, likely because pyinstaller doesn't provide a wheel, and pip is falling back to running setup.py install using setuptools. In that case, the problem lies with setuptools.

Sorry to keep passing you on to different projects, but the infrastructure is a complex mix and it's often difficult to pinpoint which part is causing an issue at first...

@pfmoore
Copy link
Member

pfmoore commented Jun 26, 2018

As a workaround, you can build a wheel using pip wheel pyinstaller and then install that wheel using pip install path-to-the-file.whl. That should use pip's wrappers, which I believe are able to handle Unicode paths for Python.

@me21
Copy link
Author

me21 commented Jun 26, 2018

Yup, that works fine. Thanks!

@kubrickfr
Copy link

Hello, yes there is a workaround but the issue is still not fixed. Can this issue be re-opened please?

@me21
Copy link
Author

me21 commented Oct 10, 2018

@kubrickfr as @pfmoore said, an issue should be opened against setuptools. This is not pip issue in the end.

@kubrickfr
Copy link

Adding link for reference:
pypa/setuptools#1400

@lock
Copy link

lock bot commented May 31, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot added the auto-locked Outdated issues that have been locked by automation label May 31, 2019
@lock lock bot locked as resolved and limited conversation to collaborators May 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation
Projects
None yet
Development

No branches or pull requests

3 participants