# Install python 3.7 in machine executor

**URL:** <https://discuss.circleci.com/t/install-python-3-7-in-machine-executor/25883>\
**Category:** Build Environment\
**Tags:** 2.0, circle-yml\
**Created:** [October 22, 2018, 6:13am UTC](https://discuss.circleci.com/t/install-python-3-7-in-machine-executor/25883 "2018-10-22T06:13:29Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![monkut](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/monkut/32/19673_2.png) [@monkut](https://discuss.circleci.com/u/monkut)\
**Post date:** [October 22, 2018, 6:13am UTC](https://discuss.circleci.com/t/install-python-3-7-in-machine-executor/25883/1 "2018-10-22T06:13:29Z")

</div>

I’m trying to get a working version of python 3.7 to run in the machine executor.

I’ve tried the following, but am getting errors:

- compile from source
  - can’t find the resulting .so python file

- installation via pyenv
  - ssl library error

- installation via the deadsnakes ppa
  - ssl library error

Here is a sample of my installation script, this currently fails due to the ‘\_ssl’ library not being linked/installed properly.

```auto
version: 2
jobs:
  build:
    machine: true

    working_directory: ~/repo

    steps:
      - checkout
      - run:
          name: install ubuntu build reqs
          command: |
            sudo apt update && sudo apt upgrade -y
            sudo apt install build-essential libssl-dev zlib1g-dev libncurses5-dev libncursesw5-dev libreadline-dev libsqlite3-dev libgdbm-dev libdb5.3-dev libbz2-dev libexpat1-dev liblzma-dev tk-dev libffi-dev
      - run:
          name: install python 3.7
          command: |
            sudo add-apt-repository --yes ppa:deadsnakes/ppa
            sudo apt-get update
            sudo apt-get install python3.7
            wget https://bootstrap.pypa.io/get-pip.py
            sudo python3.7 get-pip.py
            sudo python3.7 -m pip install --upgrade pip setuptools wheel
            sudo python3.7 -m pip install pipenv

```

Has anyone gotten python 3.7 installed and working in the machine executor?

---

<div class="post-metadata">

**Author:** ![halfer](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/halfer/32/9083_2.png) [@halfer](https://discuss.circleci.com/u/halfer)\
**Post date:** [October 22, 2018, 5:47pm UTC](https://discuss.circleci.com/t/install-python-3-7-in-machine-executor/25883/2 "2018-10-22T17:47:23Z")

</div>

What is the exact SSL error?

---

<div class="post-metadata">

**Author:** ![FelicianoTech](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/felicianotech/32/21348_2.png) [@FelicianoTech](https://discuss.circleci.com/u/FelicianoTech)\
**Post date:** [October 22, 2018, 11:51pm UTC](https://discuss.circleci.com/t/install-python-3-7-in-machine-executor/25883/3 "2018-10-22T23:51:07Z")

</div>

Hey,

So the first question is, do you really need the `machine` executor? This is simpler with Docker.

If you do need the `machine` executor, pyenv is already installed and Python v3.7.0 is pre-installed. You can try this:

```auto
version: 2
jobs:
  build:
    machine: true
    working_directory: ~/repo
    steps:
      - checkout
      - run:
          name: "Set Python Version"
          command: pyenv global 3.7.0
      - run:
          name: "Do things!"
          command: python run.py

```

---

<div class="post-metadata">

**Author:** ![monkut](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/monkut/32/19673_2.png) [@monkut](https://discuss.circleci.com/u/monkut)\
**Post date:** [October 23, 2018, 12:24am UTC](https://discuss.circleci.com/t/install-python-3-7-in-machine-executor/25883/4 "2018-10-23T00:24:50Z")

</div>

Thanks!

It’s definitely debatable if I’m doing the appropriate configuration.

I started with a testing scheme locally using docker-compose. Where the service under-development is tested by bringing up only the supporting services, and running the key service tests with the key service communicating with the docker-compose raised supporting services.

As I understand, I can spin up the whole docker-compose full service using the docker executor. But with the way my project is structured I need to run tests outside and communicate with the docker-compose network.

Anyway, your suggestion, is more what I expected and was looking for. However, when I run the config below I get the error:

ERROR:

```
#!/bin/bash -eo pipefail pyenv global 3.7.0
pyenv: version `3.7.0' not installed

```

Config:

```
version: 2
jobs:
  build:
    machine: true
    working_directory: ~/repo
    steps:
      - checkout
  - run:
      name: install python 3.7
      command: |
        pyenv global 3.7.0
        sudo python -m pip install --upgrade pip setuptools wheel
        sudo python -m pip install pipenv
```

---

<div class="post-metadata">

**Author:** ![monkut](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/monkut/32/19673_2.png) [@monkut](https://discuss.circleci.com/u/monkut)\
**Post date:** [October 23, 2018, 12:35am UTC](https://discuss.circleci.com/t/install-python-3-7-in-machine-executor/25883/5 "2018-10-23T00:35:52Z")

</div>

So as mentioned initially, I did try to install python 3.7.0 through pyenv, but the build process fails with the following error:

```
Updating /opt/circleci/.pyenv/plugins/pyenv-update...
From git://github.com/pyenv/pyenv-update
 * branch master -> FETCH_HEAD
Already up-to-date.
Downloading Python-3.7.0.tar.xz...
-> https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
Installing Python-3.7.0...
ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?

Please consult to the Wiki page to fix the problem.
https://github.com/pyenv/pyenv/wiki/Common-build-problems

BUILD FAILED (Ubuntu 14.04 using python-build 1.1.5-198-g835707da)

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

Last 10 log lines:
			install|*) ensurepip="" ;; \
		esac; \
		 ./python -E -m ensurepip \
			$ensurepip --root=/ ; \
	fi
Looking in links: /tmp/tmpucqugnjm
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
Successfully installed pip-10.0.1 setuptools-39.0.1
Exited with code 1

```

Config:  
version: 2  
jobs:  
build:  
machine: true

```
    working_directory: ~/repo

    steps:
      - checkout
      - run:
          name: update pyenv
          command: |
            # Install pyenv-update to allow addition of python 3.7.0
            git clone git://github.com/pyenv/pyenv-update.git $(pyenv root)/plugins/pyenv-update
            pyenv update
            pyenv install 3.7.0
      - run:
          name: Set Python Version
          command: pyenv global 3.7.0
      - run:
          name: install/update pip pipenv
          command: |
            sudo python -m pip install --upgrade pip setuptools wheel
            sudo python -m pip install pipenv
```

---

<div class="post-metadata">

**Author:** ![FelicianoTech](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/felicianotech/32/21348_2.png) [@FelicianoTech](https://discuss.circleci.com/u/FelicianoTech)\
**Post date:** [October 23, 2018, 5:01pm UTC](https://discuss.circleci.com/t/install-python-3-7-in-machine-executor/25883/6 "2018-10-23T17:01:14Z")

</div>

Hey,

So my apologies. What I provided before only worked because I was using a different VM. The best solution I can find is to use an updated `machine` image. The one in the example below already has Python 3.7.0:

```auto
version: 2
jobs:
  build:
    machine:
      image: circleci/classic:201808-01
    steps:
      - checkout
      - run:
          name: "Switch to Python v3.7"
          command: |
            pyenv versions
            pyenv global 3.7.0

```

You can see an example of this build running [here](https://circleci.com/gh/felicianotech/cci-testing-pub/729).

---

<div class="post-metadata">

**Author:** ![monkut](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/monkut/32/19673_2.png) [@monkut](https://discuss.circleci.com/u/monkut)\
**Post date:** [October 24, 2018, 2:39am UTC](https://discuss.circleci.com/t/install-python-3-7-in-machine-executor/25883/7 "2018-10-24T02:39:53Z")

</div>

@FelicianoTech Thanks! With the image specification I was able to run python 3.7 with the machine executor! Just what I was looking for!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/circleci/original/3X/5/1/511608acda8e85906e15909b57bd0a46c1dbe291.png) [@system](https://discuss.circleci.com/u/system)\
**Post date:** [November 3, 2018, 2:42am UTC](https://discuss.circleci.com/t/install-python-3-7-in-machine-executor/25883/8 "2018-11-03T02:42:39Z")

</div>

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
