awscli not added to path after installation
Question:
I installed the aws cli according to the offical Amazon directions.
sudo pip install awscli
However, aws
is nowhere to be found in my path. The installation seems to have been successful. There are a number of files located at /Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/awscli
, however there are no executables named aws
. My python version is 3.3.4, my pip version is 1.5.4, and running this command on OS X 10.9. What could be wrong?
Thanks!
Answers:
The solution was to add
/Library/Frameworks/Python.framework/Versions/3.3/bin
to the my PATH.
I upgraded from OSX 10.7 to OSX 10.9 and afterwards, my installation of aws no longer worked.
I observed errors like this:
$ pip
Traceback (most recent call last):
File "/usr/local/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2603, in <module>
working_set.require(__requires__)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 666, in require
needed = self.resolve(parse_requirements(requirements))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 565, in resolve
raise DistributionNotFound(req) # XXX put more info here
pkg_resources.DistributionNotFound: pip==1.5.5
The solution that the operating system upgrade had changed permissions.
Giveaway clue:
sudo pip <— worked
pip <— failed
So I did this:
sudo chmod -R a+r /Library/Python/
and then afterwards, I’m able to use the aws commands again.
Not sure if this is something that will be helpful for others, but figured I’d throw it into the mix.
When installing in a virtualenv: ‘pip install awscli’ (without sudo) worked fine on OS X; but not on CentOS release 6.6, e.g. ‘which aws’ found nothing. The solution:
chmod u+x /PATH-TO-YOUR-VIRTUALENV/bin/aws
Windows is likely the minority here, but adding below to my PATH worked for me. For reference, I installed the CLI via pip:
C:Python27Scripts
From http://docs.aws.amazon.com/cli/latest/userguide/cli-install-macos.html#awscli-install-osx-path
For Modern macos/OSX, you need to find your ~/Library/Python/$version/bin
directory and add it to your $PATH
. This will help you locate the one where aws
got installed.
$ ls -d ~/Library/Python/*/bin/aws
/Users/bbronosky/Library/Python/3.6/bin/aws
So based on that I added this line to my .bashrc
export PATH=$HOME/Library/Python/3.6/bin:$PATH
Improving the OP’s Answer
The OP answered their own question, but the exact location of the executable is more likely to be different than it is to be the same. So, let’s break down WHY his solution worked so you can apply it to yourself.
From the problem
There are a number of files located at /Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/awscli
, however there are no executables named aws.
From the solution
The solution was to add /Library/Frameworks/Python.framework/Versions/3.3/bin
to the my PATH.
Let’s learn something
Compare those paths to find their commonality:
/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/awscli
/Library/Frameworks/Python.framework/Versions/3.3/bin
Notice that they diverge at lib
vs. bin
. And consider that the OP stated, “there are no executables named aws.” That brings us to our first learning lessons:
- Executables tend to not be in
lib
folders.
- Look for
bin
folders that share a common lineage.
In this case I would have suggested looking for bin
folders via:
find /Library/Frameworks/Python.framework -type d -name bin
But, if you are going to do that, you might as well just search for your executable via:
find /Library/Frameworks/Python.framework -type f -perm -100 -name aws
# the `-` in `perm -100` means not an exact match of 100
# but any octal that includes 100
But wait
How did OP know to look in their /Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/
?
The easiest answer is also our next learning lesson:
- Ask your python where things are installed.
Here is how I do that:
$ python -c 'import awscli; print(awscli)'
<module 'awscli' from '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/awscli/__init__.pyc'>
$ python3 -c 'import awscli; print(awscli)'
<module 'awscli' from '/System/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/awscli/__init__.py'>
I have 2 Pythons and neither of them use the same paths or even path patterns as the OP.
Apply what we’ve learned
$ find /System/Library/Frameworks/Python.framework -type d -name bin
/System/Library/Frameworks/Python.framework/Versions/2.7/bin
/System/Library/Frameworks/Python.framework/Versions/3.6/bin
$ find /System/Library/Frameworks/Python.framework -type f -perm -100 -name aws
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/aws
/System/Library/Frameworks/Python.framework/Versions/3.6/bin/aws
As you can see, I have 2 bin
folders and 2 aws
executables. I probably want to use the Python3.6 version. However, if I’m doing local trial and error work for a remote system that uses the Python2.7 version, I’m going to want to use that. And this is exactly why I have 2 version installed.
Edit the paths
file directly if you have admin rights.
Definitely go with the top answer if you don’t have admin rights, but if you do then I would highly recommend directly editing the paths
files, located at /etc/paths
.
Use your favorite editor and simply paste the desired path on a new line:
Sample paths
file:
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
/Users/username/Library/Python/3.6/bin #new path added here at bottom of file
Paste at the top or bottom or in whatever order you would like the locations searched for binaries (in the event there are binaries with duplicate names).
Using the paths
file saves you the hassle of remembering the concatenation syntax or the potential trouble if you write an faulty export statement.
This worked for me on mac:
sudo -H pip install awscli --upgrade --ignore-installed six
What I typically do is copy the executable to /usr/local/bin
cp $(find / -name aws) /usr/local/bin
I had a similar problem on windows 10. I had to add below to PATH
variables
For Python:
C:UserskumarAppDataLocalProgramsPythonPython37
For PIP:
C:UserskumarAppDataLocalProgramsPythonPython37Scripts
For awscli to work:
C:UserskumarAppDataRoamingPythonPython37Scripts
Can use pip show awscli
to find the installation location.
$ pip show awscli
Name: awscli
Version: 1.16.94
Summary: Universal Command Line Environment for AWS.
Home-page: http://aws.amazon.com/cli/
Author: Amazon Web Services
Author-email: UNKNOWN
License: Apache License 2.0
Location: /root/.local/lib/python2.7/site-packages
Requires: s3transfer, colorama, rsa, docutils, botocore, PyYAML
Required-by:
On ubuntu and installed with pip3 without sudo, the correct location to add to my path was ~/.local/bin
:
export PATH=$HOME/.local/bin:$PATH
check your python version but I guessed you are using python 3.3
export PATH=$HOME/Library/Python/3.3/bin:$PATH
An alternative way is to install the aws-cli package via methods found at https://cloudacademy.com/blog/how-to-use-aws-cli/. This has worked for me 🙂
Simply download & MSI installer (64 Or 32 -bit)
Install or update the AWS CLI version 2 on Windows using the MSI installer
After installation, You may get an error "’aws’" is not recognized as an internal or external command, operable program or batch file."
Simply check Environment variable, Variable name must be ‘PATH’ and put value "C:Program FilesAmazonAWSCLIV2"
Close command prompt window and reopen it. The problem will be resolved.
export PATH=/Users/{Computer Name}/Library/Python/2.7/bin:$PATH
On some distros, if you run pip install
(without sudo
), the binaries are placed in ‘~/.local/bin’, which is not typically in the user’s path — but can be added.
Using sudo pip install
(root install) causes the packages to be put in ‘/usr/local/bin’, which should be in the user’s path. However, it includes this message on Ubuntu 22.04:
WARNING: Running pip as the ‘root’ user can result in
broken permissions and conflicting behaviour with the system package
manager. It is recommended to use a virtual environment instead:
https://pip.pypa.io/warnings/venv
Example commands to install and run aws
in a Python virtual environment…
python3 -m venv myenv && source myenv/bin/activate
pip install awscli
aws ## use awscli
deactivate ## deactivate the virtual environment
I installed the aws cli according to the offical Amazon directions.
sudo pip install awscli
However, aws
is nowhere to be found in my path. The installation seems to have been successful. There are a number of files located at /Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/awscli
, however there are no executables named aws
. My python version is 3.3.4, my pip version is 1.5.4, and running this command on OS X 10.9. What could be wrong?
Thanks!
The solution was to add
/Library/Frameworks/Python.framework/Versions/3.3/bin
to the my PATH.
I upgraded from OSX 10.7 to OSX 10.9 and afterwards, my installation of aws no longer worked.
I observed errors like this:
$ pip
Traceback (most recent call last):
File "/usr/local/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2603, in <module>
working_set.require(__requires__)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 666, in require
needed = self.resolve(parse_requirements(requirements))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 565, in resolve
raise DistributionNotFound(req) # XXX put more info here
pkg_resources.DistributionNotFound: pip==1.5.5
The solution that the operating system upgrade had changed permissions.
Giveaway clue:
sudo pip <— worked
pip <— failed
So I did this:
sudo chmod -R a+r /Library/Python/
and then afterwards, I’m able to use the aws commands again.
Not sure if this is something that will be helpful for others, but figured I’d throw it into the mix.
When installing in a virtualenv: ‘pip install awscli’ (without sudo) worked fine on OS X; but not on CentOS release 6.6, e.g. ‘which aws’ found nothing. The solution:
chmod u+x /PATH-TO-YOUR-VIRTUALENV/bin/aws
Windows is likely the minority here, but adding below to my PATH worked for me. For reference, I installed the CLI via pip:
C:Python27Scripts
From http://docs.aws.amazon.com/cli/latest/userguide/cli-install-macos.html#awscli-install-osx-path
For Modern macos/OSX, you need to find your ~/Library/Python/$version/bin
directory and add it to your $PATH
. This will help you locate the one where aws
got installed.
$ ls -d ~/Library/Python/*/bin/aws
/Users/bbronosky/Library/Python/3.6/bin/aws
So based on that I added this line to my .bashrc
export PATH=$HOME/Library/Python/3.6/bin:$PATH
Improving the OP’s Answer
The OP answered their own question, but the exact location of the executable is more likely to be different than it is to be the same. So, let’s break down WHY his solution worked so you can apply it to yourself.
From the problem
There are a number of files located at
/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/awscli
, however there are no executables named aws.
From the solution
The solution was to add
/Library/Frameworks/Python.framework/Versions/3.3/bin
to the my PATH.
Let’s learn something
Compare those paths to find their commonality:
/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/awscli
/Library/Frameworks/Python.framework/Versions/3.3/bin
Notice that they diverge at lib
vs. bin
. And consider that the OP stated, “there are no executables named aws.” That brings us to our first learning lessons:
- Executables tend to not be in
lib
folders. - Look for
bin
folders that share a common lineage.
In this case I would have suggested looking for bin
folders via:
find /Library/Frameworks/Python.framework -type d -name bin
But, if you are going to do that, you might as well just search for your executable via:
find /Library/Frameworks/Python.framework -type f -perm -100 -name aws
# the `-` in `perm -100` means not an exact match of 100
# but any octal that includes 100
But wait
How did OP know to look in their /Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/
?
The easiest answer is also our next learning lesson:
- Ask your python where things are installed.
Here is how I do that:
$ python -c 'import awscli; print(awscli)'
<module 'awscli' from '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/awscli/__init__.pyc'>
$ python3 -c 'import awscli; print(awscli)'
<module 'awscli' from '/System/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/awscli/__init__.py'>
I have 2 Pythons and neither of them use the same paths or even path patterns as the OP.
Apply what we’ve learned
$ find /System/Library/Frameworks/Python.framework -type d -name bin
/System/Library/Frameworks/Python.framework/Versions/2.7/bin
/System/Library/Frameworks/Python.framework/Versions/3.6/bin
$ find /System/Library/Frameworks/Python.framework -type f -perm -100 -name aws
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/aws
/System/Library/Frameworks/Python.framework/Versions/3.6/bin/aws
As you can see, I have 2 bin
folders and 2 aws
executables. I probably want to use the Python3.6 version. However, if I’m doing local trial and error work for a remote system that uses the Python2.7 version, I’m going to want to use that. And this is exactly why I have 2 version installed.
Edit the paths
file directly if you have admin rights.
Definitely go with the top answer if you don’t have admin rights, but if you do then I would highly recommend directly editing the paths
files, located at /etc/paths
.
Use your favorite editor and simply paste the desired path on a new line:
Sample paths
file:
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
/Users/username/Library/Python/3.6/bin #new path added here at bottom of file
Paste at the top or bottom or in whatever order you would like the locations searched for binaries (in the event there are binaries with duplicate names).
Using the paths
file saves you the hassle of remembering the concatenation syntax or the potential trouble if you write an faulty export statement.
This worked for me on mac:
sudo -H pip install awscli --upgrade --ignore-installed six
What I typically do is copy the executable to /usr/local/bin
cp $(find / -name aws) /usr/local/bin
I had a similar problem on windows 10. I had to add below to PATH
variables
For Python:
C:UserskumarAppDataLocalProgramsPythonPython37
For PIP:
C:UserskumarAppDataLocalProgramsPythonPython37Scripts
For awscli to work:
C:UserskumarAppDataRoamingPythonPython37Scripts
Can use pip show awscli
to find the installation location.
$ pip show awscli
Name: awscli
Version: 1.16.94
Summary: Universal Command Line Environment for AWS.
Home-page: http://aws.amazon.com/cli/
Author: Amazon Web Services
Author-email: UNKNOWN
License: Apache License 2.0
Location: /root/.local/lib/python2.7/site-packages
Requires: s3transfer, colorama, rsa, docutils, botocore, PyYAML
Required-by:
On ubuntu and installed with pip3 without sudo, the correct location to add to my path was ~/.local/bin
:
export PATH=$HOME/.local/bin:$PATH
check your python version but I guessed you are using python 3.3
export PATH=$HOME/Library/Python/3.3/bin:$PATH
An alternative way is to install the aws-cli package via methods found at https://cloudacademy.com/blog/how-to-use-aws-cli/. This has worked for me 🙂
Simply download & MSI installer (64 Or 32 -bit)
Install or update the AWS CLI version 2 on Windows using the MSI installer
After installation, You may get an error "’aws’" is not recognized as an internal or external command, operable program or batch file."
Simply check Environment variable, Variable name must be ‘PATH’ and put value "C:Program FilesAmazonAWSCLIV2"
Close command prompt window and reopen it. The problem will be resolved.
export PATH=/Users/{Computer Name}/Library/Python/2.7/bin:$PATH
On some distros, if you run pip install
(without sudo
), the binaries are placed in ‘~/.local/bin’, which is not typically in the user’s path — but can be added.
Using sudo pip install
(root install) causes the packages to be put in ‘/usr/local/bin’, which should be in the user’s path. However, it includes this message on Ubuntu 22.04:
WARNING: Running pip as the ‘root’ user can result in
broken permissions and conflicting behaviour with the system package
manager. It is recommended to use a virtual environment instead:
https://pip.pypa.io/warnings/venv
Example commands to install and run aws
in a Python virtual environment…
python3 -m venv myenv && source myenv/bin/activate
pip install awscli
aws ## use awscli
deactivate ## deactivate the virtual environment