pyenv unable to find docker-compose

Viewed 815

I think I may have screwed up my local py environment on my Mac.

I've installed pyenv and a couple of python versions:

$ pyenv global
2.7.17
3.7.7

It seems to have decided to wrap itself around docker-compose...

$ which docker-compose
/Users/wintermute/.pyenv/shims/docker-compose

I've got a local env I want to run python3 in:

$ cd mysite
$ pyenv version
3.7.7 (set by /Users/wintermute/mysite/.python-version)

But now I can't run docker-compose in it:

$ docker-compose up
pyenv: docker-compose: command not found

The `docker-compose' command exists in these Python versions:
  2.7.5

Note: See 'pyenv help global' for tips on allowing both
  python2 and python3 to be found.

And worse, it won't even run in the version it says to use:

$ pyenv local 2.7.5
$ docker-compose up -d
ERROR:root:code for hash md5 was not found.
(and a load of debug traceback messages)

I've tried pyenv rehash. I think I originally had python installed via homebrew. What can I do to unscrew my local environment? Why can't it find docker-compose? What have I done??

1 Answers

I was using the command eval "$(pyenv init -)" in my ~/.zshrc to enable pyenv. You need to check your .bashrc or .zshrc for a similar command. This modifies the PATH and put the shims first which creates the issue. (You can run pyenv init - to see what happens). Remove the eval and manually added the shims to the path AFTER the existing PATH.

export PATH="${PATH}:"$(pyenv root)/shims

I haven't thoroughly tested it, but it fixes the docker-compose issue. Check out Pyenv Advanced Configuration for more info.

Related