Elaraks
Elaraks

Reputation: 13

Installing docker failing at 'Clean previous docker-py package if installing docker', syntax error

I'm currently trying to run an ansible playbook (here: https://github.com/forensic-architecture/devops), one of the first tasks being installing this docker: https://github.com/angstwad/docker.ubuntu. However, this keeps failing at the task "Clean previous docker-py package if installing docker", with the error message below:

fatal: [ec2-IPXADDRESS-compute-1.amazonaws.com]: 
FAILED! => {"changed": false, "cmd": ["/usr/local/bin/pip", "uninstall", "-y", "docker-py"], 
"msg": "\n:stderr: Traceback (most recent call last):\n  
File \"/usr/local/bin/pip\", line 7, in <module>\n   from pip._internal.cli.main import main\n  
File \"/usr/local/lib/python3.5/dist-packages/pip/_internal/cli/main.py\", line 58\n    
sys.stderr.write(f\"ERROR: {exc}\")\n                                   ^\nSyntaxError:
invalid syntax\n"}

I don't have a file at '/usr/local/lib/python3.5/', and I don't have python 3.5, so this has been confusing me. I have my hosts file pointing to where I have python ([myhost] ansible_python_interpreter=/Users/myname/.pyenv/shims/python3).

I removed the task it keeps failing at and ran it to see what would happen, I just got the same error message later down the line (at TASK [pip], in the first playbook rather than the angstwad.docker installation one which it completed with the cleaning task removed).

I'm unsure what to do; if more information is needed from me to help with this please let me know, as I'm very new to this so unsure what is relevant and what is not.

Would installing python 3.5 help? I tried installing a few different versions of 3.5 but kept getting this error message:

BUILD FAILED (OS X 11.3.1 using python-build 20180424)

Inspect or clean up the working tree at /var/folders/jt/48lrg2192p5cld7sslf750km0000gn/T/python-build.20210522120347.5181
Results logged to /var/folders/jt/48lrg2192p5cld7sslf750km0000gn/T/python-build.20210522120347.5181.log

Last 10 log lines:
checking size of _Bool... 1
checking for uintptr_t... yes
checking size of uintptr_t... 8
checking size of off_t... 8
checking whether to enable large file support... no
checking size of time_t... 8
checking for pthread_t... yes
checking size of pthread_t... 8
configure: error: Unexpected output of 'arch' on OSX
make: *** No targets specified and no makefile found.  Stop.

UPDATE

I realised yesterday that the devops repository tells you to run it in a virtualenv; I thought this might be why I'm coming across this issue, so have retried within that, as was hoping that this would sort what seems to be to be some sort of python incompatibility error.

However, I'm still coming up against the same error. Here it is in -vvv if that's helpful.

fatal: [ec2-X.compute-1.amazonaws.com]: FAILED! => {
    "changed": false,
    "cmd": [
        "/usr/local/bin/pip3",
        "uninstall",
        "-y",
        "docker-py"
    ],
    "invocation": {
        "module_args": {
            "chdir": null,
            "editable": false,
            "executable": "pip3",
            "extra_args": null,
            "name": [
                "docker-py"
            ],
            "requirements": null,
            "state": "absent",
            "umask": null,
            "version": null,
            "virtualenv": null,
            "virtualenv_command": "virtualenv",
            "virtualenv_python": null,
            "virtualenv_site_packages": false
        }
    },
    "msg": "\n:stderr: Traceback (most recent call last):\n  File
 \"/usr/local/bin/pip3\", line 7, in <module>\n    from
pip._internal.cli.main import main\n  File
\"/usr/local/lib/python3.5/dist-packages/pip/_internal/cli/main.py\", line
58\n    sys.stderr.write(f\"ERROR: {exc}\")\n
                                  ^\nSyntaxError: invalid syntax\n"

Upvotes: 1

Views: 117

Answers (1)

Jong
Jong

Reputation: 26

Upgrade your python to at least 3.6

That version of pip doesn't support version 3.5 as the older python version doesn't include f-strings which were introduced in 3.6.

Upvotes: 1

Related Questions