1

I was using both Python, Python3 and aws-cli very well. However, after installing kyoto-cabinet via brew, I saw cleanup not done in 30 days, running brew cleanup now message and then brew cleanup was performed. After this, I am unable to use aws cli.

I tried this solution(Broken references in Virtualenvs) but in vain.

My command followed by the error is:

➜  pallet-core git:(master) ✗ aws
dyld: Library not loaded: @executable_path/../.Python
  Referenced from: /usr/local/aws/bin/python2.7
  Reason: image not found
[1]    1474 abort      aws

My python2 version is:

➜  pallet-core git:(master) python2 --version
Python 2.7.16

There is no active virtualenv as well.

➜  pallet-core git:(master) which python
/usr/bin/python

I expect aws cli to run as it should.

Aviral Srivastava
  • 4,058
  • 8
  • 29
  • 81
  • What do you get if you run 'which aws'? – Sina Apr 29 '19 at 21:57
  • `/usr/local/bin/aws` – Aviral Srivastava Apr 30 '19 at 03:39
  • But running something like `aws --version` doesn't work? Have you tried just reinstalling the aws cli? https://docs.aws.amazon.com/cli/latest/userguide/install-macos.html – Sina Apr 30 '19 at 22:51
  • No, it didn't work. I ran two commands: `sudo pip3 install --no-cache-dir --upgrade --force-reinstall awscli --user` and normal pip3 install. Both of them didn't work upon checking `aws --version`. I get the same error. – Aviral Srivastava May 01 '19 at 04:21

1 Answers1

3

Install Python via pyenv

Install dependencies

sudo apt-get update sudo apt-get install make build-essential libssl-dev 
zlib1g-dev libbz2-dev \ libreadline-dev libsqlite3-dev wget curl llvm 
libncurses5-dev libncursesw5-dev \ xz-utils tk-dev libffi-dev liblzma-dev

Install pyenv

https://github.com/pyenv/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 echo -e 'if command -v pyenv 
1>/dev/null 2>&1; then\n  eval "$(pyenv init -)"\nfi' >> ~/.bashrc

Close and reopen your terminal, or: source ~/.bashrc

Check Installation: command -v pyenv

Install pyenv-virtualenv https://github.com/pyenv/pyenv-virtualenv

git clone https://github.com/pyenv/pyenv-virtualenv.git $(pyenv 
root)/plugins/pyenv-virtualenv echo 'eval "$(pyenv virtualenv-init -)"' >> 
~/.bashrc

Close and reopen your terminal, or: source ~/.bashrc

Install Python To install a specific python version using pyenv and set it as your global python, then run the following substituting in your desired python version:

pyenv install <python_version> pyenv global <python_version> pip install -- 
upgrade pip

Check installation: python --version

To create a virtualenv based on the currently active python version: pyenv virtualenv To automatically activate and deactivate a virtualenv on entering a relevant

directory then create a file at the desired level, e.g. at the .python-version root of the a folder to activate the virtual env for a repos. The file should just contain the name of the virtualenv you wish to activate. Install AWS CLI http://docs.aws.amazon.com/cli/latest/userguide/installing.html

#Activate your virtualenv pyenv activate <virtualenv_name>
pip install awscli

Configure AWS CLI

http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html Generate a access key: Login to the AWS console Navigate to your user in IAM Generate yourself a Access Key Download the .csv Run the following in the terminal:

aws configure
#When prompted enter the following: # - enter generated AWS Access Key ID # 
- enter generated AWS Secret Access Key # - us-west-2 # - json
amittn
  • 2,249
  • 1
  • 12
  • 19
  • Thanks, but I am on Mac. Sorry for informing this late. – Aviral Srivastava May 02 '19 at 10:46
  • @AviralSrivastava On mac, I have shared with you the github link's on each and every step. Just to inform few of my team mates have used the drew setup described there in the readme. hope that helps you as well https://github.com/pyenv/pyenv and https://github.com/pyenv/pyenv-virtualenv – amittn May 02 '19 at 11:18
  • few corrections and it worked like a charm. PS For anyone who faces any problem at `sudo pyenv install 3.5.2`, refer to this(https://stackoverflow.com/a/52600628/10834788) as well. – Aviral Srivastava May 06 '19 at 09:49