A struggle when installing pyenv on Cygwin

A record of installing pyenv on Cygwin. I could or couldn't install it with the python version.

Environment: Cygwin (Setup version 2.900 (64 bit))

change history: 2020/01/17 First draft 2020/01/19 Added about the matter that the pyenv function does not work

--Install pyenv on Cygwin
I couldn't find the pyenv package in Cygwin Setup, so I installed it with git.

$ git clone https://github.com/pyenv/pyenv.git ~/.pyenv

--Environment variable settings

$ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_bashrc
$ echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_bashrc
$ echo 'eval "$(pyenv init -)"' >> ~/.bash_bashrc
$ source ~/.bash_bashrc

--Confirmation of python that can be installed with pyenv.

$ pyenv install --list
Available versions:
  2.1.3
  2.2.3
  2.3.7
The following is omitted

--Installing python
First, I installed python 3.7.6.

$ pyenv install 3.7.6
Downloading Python-3.7.6.tar.xz...
-> https://www.python.org/ftp/python/3.7.6/Python-3.7.6.tar.xz
Installing Python-3.7.6...
WARNING: The Python bz2 extension was not compiled. Missing the bzip2 lib?
WARNING: The Python sqlite3 extension was not compiled. Missing the SQLite3 lib?
Installed Python-3.7.6 to /home/xxxx/.pyenv/versions/3.7.6

Installation takes time because it installs the specified version of python in your pyenv environment. It took about 10 minutes on my PC.

Since WARNING came out, I responded as follows. ** WARNING: The Python bz2 extension was not compiled. Missing the bzip2 lib? ** support Install the package libbz2-devel with Cygwin Setup, uninstall it with
pyenv uninstall -f 3.7.6
, and then run
pyenv install 3.7.6
again to solve the problem.

** WARNING: The Python sqlite3 extension was not compiled. Missing the SQLite3 lib? ** I installed sqlite3 related packages with Cygwin Setup (eventually installed all sqlite3 related packages), but WARNING was not resolved.
Therefore, uninstall all sqlite3 related packages with Cygwin Setup, and download the source (sqlite-autoconf-3300100.tar.gz) from the SQLite download site (* 1). Unzip, ./configure, make, make install to install SQLite3 (default / usr / local) and pyenv install again to solve.

※1https://www.sqlite.org/download.html

--Installing python 3.6.10
I got the following error.

$ pyenv install 3.6.10
Downloading Python-3.6.10.tar.xz...
-> https://www.python.org/ftp/python/3.6.10/Python-3.6.10.tar.xz
Installing Python-3.6.10...

BUILD FAILED (CYGWIN_NT-6.1 3.1.2(0.340/5/3) using python-build 1.2.16-1-g4500a33c)

Inspect or clean up the working tree at /tmp/python-build.20200114100336.19695
Results logged to /tmp/python-build.20200114100336.19695.log

Last 10 log lines:
     PyStructSequence_SET_ITEM(result, 6, PyLong_FromLong(si->si_band));
                                                              ^
./Include/tupleobject.h:62:75:Remarks: in definition of macro ‘PyTuple_SET_ITEM’
 #define PyTuple_SET_ITEM(op, i, v) (((PyTupleObject *)(op))->ob_item[i] = v)
                                                                           ^
./Modules/signalmodule.c:979:5:Remarks: in expansion of macro ‘PyStructSequence_SET_ITEM’
     PyStructSequence_SET_ITEM(result, 6, PyLong_FromLong(si->si_band));
     ^~~~~~~~~~~~~~~~~~~~~~~~~
make: *** [Makefile:1782: Modules/signalmodule.o]Error 1
make: ***Waiting for an incomplete job....

There is a compilation error in ./Modules/signalmodule.c. So I compared the ./Modules/signalmodule.c source of Python-3.7.6, which was successfully installed, with Python-3.6.10, which had a compilation error.

python


◎python-3.6.10./Modules/signalmodule.Where an error occurred in c
    PyStructSequence_SET_ITEM(result, 6, PyLong_FromLong(si->si_band));

◎python-3.7.6 of./Modules/signalmodule.Same place with c
#ifdef HAVE_SIGINFO_T_SI_BAND
    PyStructSequence_SET_ITEM(result, 6, PyLong_FromLong(si->si_band));
#else
    PyStructSequence_SET_ITEM(result, 6, PyLong_FromLong(0L));
#endif

Looking at the top, you can see that in python-3.7.6, the processing is separated by the HAVE_SIGINFO_T_SI_BAND switch. Looking at the configure of the python-3.7.6 installation package, I checked the Cygwin header and set the HAVE_SIGINFO_T_SI_BAND switch to 1 if the si_band was present in the siginfo_t structure, otherwise nothing was done ( It corresponds to Issue # 21085). Therefore, python-3.7.6 did not cause a compile error. In fact, si_band does not exist in Cygwin's siginfo_t structure. So python-3.6.10 unconditionally refers to si_band of siginfo_t, so an error occurred. After checking, I found an article (* 2) that the environment variable PYTHON_BUILD_CACHE_PATH can be set and the cached source can be installed, so I used it to change ./Modules/signalmodule.c of python-3.6.10 to python-3.7.6. I thought that I should change it and install it.

※2 https://github.com/pyenv/pyenv/tree/master/plugins/python-build

Actually, I tried the following procedure.

$ pyenv install -k 3.6.10   *1
⇒ An error will occur,$PYENV_ROOT/sources/3.6.Python downloaded to 10-3.6.10.tar.xz remains.
[Manual operation] Python-3.6.10.tar.Unzip and unzip xz in a suitable location.
I got an error./Modules/signalmodule.c to python-3.7.Modify it like the code in 6
New python-3.6.10.tar.Create xz.
$ mkdir $PYENV_ROOT/cache   *2
[Manual operation] The newly created Python-3.6.10.tar.xz$PYENV_ROOT/Copy to cache.
$ PYTHON_BUILD_CACHE_PATH=$PYENV_ROOT/cache pyenv install 3.6.10   *3

But still Downloading Python-3.6.10.tar.xz... -> https://www.python.org/ftp/python/3.6.10/Python-3.6.10.tar.xz Is displayed and downloaded from the server. In addition, when I put the package downloaded from the python server in the cache and installed it by using the cache, it was not downloaded. Upon further investigation, in the Join GitHub today article (* 3), it seems that the package to be installed must be the correct SHA256 checksum defined in pyenv. I abandoned the installation of Python-3.6.10 by this method because it is more difficult than this.

※3 https://github.com/pyenv/pyenv/issues/563

The installation command is

$ pyenv help install
Usage: pyenv install [-f] [-kvp] <version>
       pyenv install [-f] [-kvp] <definition-file>
       pyenv install -l|--list
       pyenv install --version

  -l/--list          List all available versions
  -f/--force         Install even if the version appears to be installed already
  -s/--skip-existing Skip if the version appears to be installed already

  python-build options:

  -k/--keep          Keep source tree in $PYENV_BUILD_ROOT after installation
                     (defaults to $PYENV_ROOT/sources)
  -p/--patch         Apply a patch from stdin before building
  -v/--verbose       Verbose mode: print compilation status to stdout
  --version          Show version of python-build
  -g/--debug         Build a debug version

So, there seems to be another way to specify \ <definition-file > and patch and install with --patch, but I couldn't find any useful information and gave up. If you have time, I'd love to see the pyenv source! I think I should ask the head family to correct it, but I can't because I can't speak English, I haven't done it, and I don't know the style.

--In addition, I installed python 2.7.17 and python 3.5.9, but an error occurred. I'm not chasing deeply.

--The installation of python 3.8.1 was successful.

$ pyenv install 3.8.1
Downloading Python-3.8.1.tar.xz...
-> https://www.python.org/ftp/python/3.8.1/Python-3.8.1.tar.xz
Installing Python-3.8.1...
Installed Python-3.8.1 to /home/xxxx/.pyenv/versions/3.8.1

$ pyenv versions
* system (set by /home/xxxx/.pyenv/version)
  3.7.6
  3.8.1

--Checking the operation of pyenv

Well, I was able to install python 3.7.6 and python 3.8.1 on pyenv, but I stumbled again when I checked the operation.

$ pyenv global 3.8.1

$ pyenv versions
  system
  3.7.6
* 3.8.1 (set by /home/xxxx/.pyenv/version)

$ python -V
Python 2.7.16

$ pyenv which python
/usr/bin/python

And, python installed by Cygwin package is executed and pyenv is not working. So I compared it with that of ubuntu where pyenv is running. Then, it turned out that the symbolic link that exists in ubuntu's pyenv environment does not exist in Cygwin's pyenv environment. Perhaps I should look into $ PYENV_ROOT / plugins / python-build \ bin / python-build (bash script), but I didn't feel like doing that. As a response, ** manually ** created the following symbolic link.

◎python 3.7.Symbolic link to 6

$ cd $PYENV_ROOT/versions/3.7.6
$ ln -s easy_install-3.7 easy_install
$ ln -s idle3.7 idle
$ ln -s pip3.7 pip
$ ln -s pydoc3.7 pydoc
$ ln -s python3.7m.exe python
$ ln -s python3.7-config python-config

◎python 3.8.Symbolic link to 1

$ cd $PYENV_ROOT/versions/3.8.1
$ ln -s easy_install-3.8 easy_install
$ ln -s idle3.8 idle
$ ln -s pip3.8 pip
$ ln -s pydoc3.8 pydoc
$ ln -s python3.8.exe python-buildpython
$ ln -s python3.8-config python-config

After that, pyenv started to work as follows.

$ pyenv init
$ pyenv rehash

$ pyenv global 3.7.6
$ pyenv versions
  system
* 3.7.6 (set by /home/xxxx/.pyenv/version)
  3.8.1
$ python -V
Python 3.7.6
$ pyenv which python
/home/xxxx/.pyenv/versions/3.7.6/bin/python

$ pyenv global 3.8.1
$ pyenv versions
  system
  3.7.6
* 3.8.1 (set by /home/xxxx/.pyenv/version)
$ python -V
Python 3.8.1
$ pyenv which python
/home/xxxx/.pyenv/versions/3.8.1/bin/python

$ pyenv global system
$ pyenv versions
* system (set by /home/xxxx/.pyenv/version)
  3.7.6
  3.8.1
$ python -V
Python 2.7.16
$ pyenv which python
/usr/bin/python

--Summary

The result of python installation with pyenv is as follows. python 2.7.17 Failure python 3.5.9 failed python 3.6.10 failed python 3.7.6 Success python 3.8.1 success

Even so, even if the installation was successful, it didn't work obediently, and I had to manually handle it individually (I'm not sure how correct this is). For the time being, the specified version of python works, but there is no guarantee that various new troubles will not occur when using that python. At the moment, I felt it would be wise to avoid using pyenv with Cygwin.

I hope it will be helpful for those who are having a hard time. Also, I would appreciate any information that you can install it this way.

that's all

Recommended Posts

A struggle when installing pyenv on Cygwin
Installing pyenv on ubuntu 16.04
Support when installing pillow on python3.9
Notes on installing Python using PyEnv
Error resolution when installing numba on macOS
A workaround when installing pyAudio with pip.
Check! Troubleshooting when installing PyObjc on Mac
Error when installing a module with Python pip
A addictive story when using tensorflow on Android
[Grasshopper] When creating a data tree on Python script
Precautions when installing a hierarchical include directory with waf
What I did when I stumbled on a Django tutorial
I got a UnicodeDecodeError when pip install on ubuntu
A memo of installing Chainer 1.5 for GPU on Windows
SoC FPGA: A small story when using on Linux
Build a Python environment on your Mac using pyenv
Build a Python development environment using pyenv on MacOS
A memo when Django was released on VPS (preparation)
A swampy story when using firebase on AWS lamda
Minimum memo when using Python on Mac (pyenv edition)
A memorandum regarding Wifi connection when installing Arch Linux
Python conda on cygwin
Install pyenv on mac
Stumbled when installing PyOCR
Notes on installing PycURL
Installing pandas on python2.6
Precautions when installing fbprophet
Install pyenv on OSX
Build a machine learning environment on mac (pyenv, deeplearning, opencv)
Create a Python (pyenv / virtualenv) development environment on Mac (Homebrew)
Options when installing libraries that cannot be piped with pyenv
A solution when you can't start project Django on Windows
[GCP] A memorandum when running a Python program on Cloud Functions
Precautions and solutions when installing Ubuntu on NVIDIA GeForce PCs
(Note) Points to be addicted to when installing Scilab on ArchLinux
A note when I can't open Jupyter Notebook on Windows
When you want to hit a UNIX command on Python
List of libraries to install when installing Python using Pyenv
Until building a Python development environment using pyenv on Ubuntu 20.04