Z
Z
Zadavatel_Voprosov2018-07-08 14:08:19
Python
Zadavatel_Voprosov, 2018-07-08 14:08:19

Can't build Python 3.7 from official sources?

All good and hello! I want to put myself a newer "Snake", namely 3.7 ( because some of the window family does not want to work ). First I download the sources from the site, I make sudo make altinstalla mistake here too.
I run to the official docks , download CPython from GitHub , compile, and at the same moment I get the same error. What to do (please tell me)?
Oops, here's the error:

running install_scripts
copying build/scripts-3.7/idle3.7 -> /usr/local/bin
copying build/scripts-3.7/pydoc3.7 -> /usr/local/bin
copying build/scripts-3.7/pyvenv-3.7 -> /usr/local/bin
copying build/scripts-3.7/2to3-3.7 -> /usr/local/bin
changing mode of /usr/local/bin/idle3.7 to 755
changing mode of /usr/local/bin/pydoc3.7 to 755
changing mode of /usr/local/bin/pyvenv-3.7 to 755
changing mode of /usr/local/bin/2to3-3.7 to 755
rm /usr/local/lib/python3.7/lib-dynload/_sysconfigdata_m_linux_x86_64-linux-gnu.py
rm -r /usr/local/lib/python3.7/lib-dynload/__pycache__
/usr/bin/install -c -m 644 ./Misc/python.man \
  /usr/local/share/man/man1/python3.7.1
if test "xupgrade" != "xno"  ; then \
  case upgrade in \
    upgrade) ensurepip="--altinstall --upgrade" ;; \
    install|*) ensurepip="--altinstall" ;; \
  esac; \
   ./python -E -m ensurepip \
    $ensurepip --root=/ ; \
fi
Traceback (most recent call last):
  File "/home/timosha/cpython-3.7/Lib/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/timosha/cpython-3.7/Lib/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/timosha/cpython-3.7/Lib/ensurepip/__main__.py", line 5, in <module>
    sys.exit(ensurepip._main())
  File "/home/timosha/cpython-3.7/Lib/ensurepip/__init__.py", line 204, in _main
    default_pip=args.default_pip,
  File "/home/timosha/cpython-3.7/Lib/ensurepip/__init__.py", line 117, in _bootstrap
    return _run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
  File "/home/timosha/cpython-3.7/Lib/ensurepip/__init__.py", line 27, in _run_pip
    import pip._internal
  File "/tmp/tmpv8cl2p7b/pip-10.0.1-py2.py3-none-any.whl/pip/_internal/__init__.py", line 42, in <module>
  File "/tmp/tmpv8cl2p7b/pip-10.0.1-py2.py3-none-any.whl/pip/_internal/cmdoptions.py", line 16, in <module>
  File "/tmp/tmpv8cl2p7b/pip-10.0.1-py2.py3-none-any.whl/pip/_internal/index.py", line 25, in <module>
  File "/tmp/tmpv8cl2p7b/pip-10.0.1-py2.py3-none-any.whl/pip/_internal/download.py", line 39, in <module>
  File "/tmp/tmpv8cl2p7b/pip-10.0.1-py2.py3-none-any.whl/pip/_internal/utils/glibc.py", line 3, in <module>
  File "/home/timosha/cpython-3.7/Lib/ctypes/__init__.py", line 7, in <module>
    from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'
Makefile:1132: ошибка выполнения рецепта для цели «altinstall»
make: *** [altinstall] Ошибка 1
PS: All commands were executed as root (sudo) _-| Ubuntu 16.04.4 LTS |-_

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
sim3x, 2018-07-08
@Zadavatel_Voprosov

Guide
How to install the required version of python for one user in the home directory
You do not need to change the system python
Run like this python3.7 -v
Wrong python3 -v
Why? What is required to install for assembly in ubunts 16.xx-18.xxwhich python3.7; which python3

apt-get install -y \
  build-essential git libexpat1-dev libssl-dev zlib1g-dev \
  libncurses5-dev libbz2-dev liblzma-dev \
  libsqlite3-dev libffi-dev\
  libffi-dev tcl-dev linux-headers-generic libgdbm-dev \
  libreadline-dev tk-dev \
  libdb-dev \
  libmpdec-dev \
  libncursesw5-dev

ref
https://packages.ubuntu.com/source/artful/python3.6
https://stackoverflow.com/a/51224996/1346222

We get the sources and check out the required version
cd /tmp
git clone https://github.com/python/cpython.git
cd cpython
git checkout 3.7

Please note
Not the installer will create such dirs Do before and after , then there will be no questions about what the python put Before any operation - you need to read the mana! For example, if it is supposed to build different variants of python , it can greatly speed up the process -j4 will hang the assembly on 4 cores, if you have them of course--prefix=$HOME/.local/bin--prefix=$HOME/.local${prefix}/{bin,include,lib,share}
./configure --prefix=$HOME/.local --enable-optimizations
make -j4
make install

the installer forms such a structure for python
Before installation, it is advisable to remove everything by hand. Not directories . There can be a lot of software in this directory
.local
├── bin
│   ├── 2to3 -> 2to3-3.7
│   ├── 2to3-3.7
│   ├── easy_install-3.7
│   ├── idle3 -> idle3.7
│   ├── idle3.7
│   ├── pip3
│   ├── pip3.7
│   ├── pydoc3 -> pydoc3.7
│   ├── pydoc3.7
│   ├── python3 -> python3.7
│   ├── python3.7
│   ├── python3.7-config -> python3.7m-config
│   ├── python3.7m
│   ├── python3.7m-config
│   ├── python3-config -> python3.7-config
│   ├── pyvenv -> pyvenv-3.7
│   └── pyvenv-3.7
├── include
│   └── python3.7m
├── lib
│   ├── libpython3.7m.a
│   ├── pkgconfig
│   └── python3.7
│   └── man

If after installation and assembly which python3.7it does not give a result - check for the presence in PATH ~./local/bin
$ grep "$HOME/.local/bin:" <<< "$PATH"  
/home/sim3x/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:

L
lega, 2018-07-09
@lega

Instructions on how to install and build a python deb package in a few steps , which can later be installed on other hosts without any problems. + can be removed/updated via dpkg.
Relevant for all versions of python and Ubuntu 12/14/16 (just substitute the correct link).
You can also use any python through docker:
docker run -it python:3.7

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question