Pyenv Fails To Install Python On Cygwin: Modulenotfounderror: No Module Named '_ctypes'
Solution 1:
I found a solution for mapping pre-installed python binaries in pyenv (without using pyenv install <version>
), however, it will only work for python versions installed using setup-x86_64.exe
. Python is quite troublesome to compile in Cygwin.
- Install pyenv
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
echo'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
Install Python using
setup-x86_64.exe
. For this example I installed the following packages:python3
(version 3.6.9)python36-pip
python36-virtualenv
(optional, in case you work with virtualenv)
To manually add an existing python version to pyenv, create a folder
.pyenv/versions/<your-version-name>/bin
and add link to binaries there:
mkdir ~/.pyenv/versions/3.6.9/bin/
cd ~/.pyenv/versions/3.6.9/bin/
ln -s /usr/bin/python3.6m.exe python3.6
ln -s python3.6 python3
ln -s python3 python
ln -s /usr/bin/pip3.6 pip3.6
ln -s pip3.6 pip3
ln -s pip3 pip
ln -s /usr/bin/virtualenv-3.6 virtualenv-3.6
ln -s virtualenv-3.6 virtualenv-3
ln -s virtualenv-3 virtualenv
PS: I imagine that other python versions can be installed through the regular windows system and symlinked likewise inside cygwin.
Solution 2:
Even though you have libffi-devel
installed (which is needed in the first place), you won't be able to compile _ctypes
and certain other extension modules due to a long-known bug in distutils for finding the import libraries needed to link extension modules with requirements on third-party libraries (such as libffi in this case).
There is a recently updated pull request to fix this issue, which has been sitting in wait of review for almost two years now. If you'd like to test the PR, and maybe add a comment to it confirming that it works and is needed, it might help move it along to getting merged...
Post a Comment for "Pyenv Fails To Install Python On Cygwin: Modulenotfounderror: No Module Named '_ctypes'"