question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

setup.py not compatible for setting up a development installation on a windows machine

See original GitHub issue

As per setup guide , pip install -e . fails to install optuna for development on a windows machine/environment.

Expected behavior

It should install optuna with dev dependencies without any errors.

Environment

  • Windows 10/11
  • python 3.9.1
  • pip 21.2.4
  • setuptools 58.2.0
  • wheel 0.37.0
  • optuna : current master

Error messages, stack traces, or logs

Installing build dependencies ... done
Getting requirements to build wheel ... error
ERROR: Command errored out with exit status 1:
command: 'c:\python\python.exe' 'c:\python\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py' get_requires_for_build_wheel 'C:\Users\91728\AppData\Local\Temp\tmprb137rje'
      cwd: C:\Users\91728\Desktop\optuna\optuna
Complete output (22 lines):
  Traceback (most recent call last):
    File "c:\python\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 349, in <module>
      main()
    File "c:\python\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 331, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "c:\python\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 117, in get_requires_for_build_wheel
      return hook(config_settings)
    File "C:\Users\91728\AppData\Local\Temp\pip-build-env-h54rpc43\overlay\Lib\site-packages\setuptools\build_meta.py", line 154, in get_requires_for_build_wheel
      return self._get_build_requires(
    File "C:\Users\91728\AppData\Local\Temp\pip-build-env-h54rpc43\overlay\Lib\site-packages\setuptools\build_meta.py", line 135, in _get_build_requires
      self.run_setup()
    File "C:\Users\91728\AppData\Local\Temp\pip-build-env-h54rpc43\overlay\Lib\site-packages\setuptools\build_meta.py", line 258, in run_setup
      super(_BuildMetaLegacyBackend,
    File "C:\Users\91728\AppData\Local\Temp\pip-build-env-h54rpc43\overlay\Lib\site-packages\setuptools\build_meta.py", line 150, in run_setup
      exec(compile(code, __file__, 'exec'), locals())
    File "setup.py", line 194, in <module>
      long_description=get_long_description(),
    File "setup.py", line 25, in get_long_description
      return f.read()
    File "c:\python\lib\encodings\cp1252.py", line 23, in decode
      return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in position 2146: character maps to <undefined>

Steps to reproduce

  1. Use windows machine/environment
  2. git clone ########/optuna.git
  3. cd optuna
  4. pip install -e .

Additional context

The UnicodeDecodeError happens here because generally text encoding in a windows machine is cp1252. You can see output of [System.Text.Encoding]::Default from my machine below.

IsSingleByte      : True
BodyName          : iso-8859-1
EncodingName      : Western European (Windows)
HeaderName        : Windows-1252
WebName           : Windows-1252
WindowsCodePage   : 1252
IsBrowserDisplay  : True
IsBrowserSave     : True
IsMailNewsDisplay : True
IsMailNewsSave    : True
EncoderFallback   : System.Text.InternalEncoderBestFitFallback
DecoderFallback   : System.Text.InternalDecoderBestFitFallback
IsReadOnly        : True
CodePage          : 1252

And, encoding of README.md file is UTF-8.

$ file --mime-encoding README.md
README.md: utf-8

So, I think get_long_description function fails to parse the file in a windows environment. My insights are derived from here.

So, changing this line to with open(readme_filepath, encoding="utf8") as f: would hopefully resolve this error.

I would love to open a PR with the changes if this feels suitable.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
toshihikoyanasecommented, Oct 18, 2021

Thank you for reporting the issue. I was not aware of that since I usually develop optuna on WSL2. UnicodeDecodeError occurred because the encoding default was cp932.

As a workaround, I successfully installed optuna from the source with PYTHONUTF8=1.

> $env:PYTHONUTF8 = 1
> pip install -e .

Not a strong opinion, but it may be too early to modify the code for Windows. The reasons are as follows:

  1. Optuna repository doesn’t have CI environment for Windows as @nzw0301 mentioned. Most of the committers use macOS or Linux, and we may not be able to review changes for Windows.
  2. The issue affects only developers on Windows. Users can simply install optuna with pip install optuna.
  3. We have the workaround to avoid UnicodeDecodeError.
1reaction
nzw0301commented, Oct 18, 2021

I suppose @himkt @toshihikoyanase use Windows. What do you think about this proposal 🙇🏻 ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python setup.py develop vs install - Stack Overflow
I ran into problems using python setup.py develop trying to set up Ceilometer for local development. I ended up using pip install -e...
Read more >
Setting up a development install - JupyterHub
Install Python ​​ JupyterHub is written in the Python programming language and requires you have at least version 3.6 installed locally. If you...
Read more >
How to set up Setuptools for Python on Windows?
Method 1: Using pip to install Setuptools Package ; Step 1: Install the latest or current version of Python3 in Windows. ; Step...
Read more >
Development Mode (a.k.a. “Editable Installs”) - Setuptools
An “editable installation” works very similarly to a regular install with pip install . , except that it only installs your package dependencies, ......
Read more >
Installing Python Modules (Legacy version) — Python 3.11.1 ...
This guide only covers the basic tools for building and distributing extensions ... is not supported under Windows, which means that pure Python...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found