1

I am currently working on a mongo db assignment using pymongo, as part of it we need to install python bottle framework. I have installed bottle on the Mac using the below command:

$ pip install bottle

got the below message returned.

Requirement already satisfied: bottle in /Library/Python/2.7/site-packages

when I run a program from terminal which uses bottle, it throws the below error:

$ python hello_m101p.py  
Traceback (most recent call last):
File "hello_m101p.py", line 2, in <module>
import bottle
ModuleNotFoundError: No module named 'bottle'

I noted that i also have python 3.6.4 version installed on my system. I need bottle framework to be saved or installed for this version instead of the default 2.7 version. After a quick lookup around stack overflow, I tried the below command from one the suggested answers. I get the command not found error:

sudo pip-3.6.4 install bottle

sudo: pip-3.6.4: command not found

Any help to correct this error ? I am not sure how to address this. Please let me know if the question is unclear or need more context.

Kiran
  • 25
  • 4
  • The `pip` command that you want should be called `pip3.6` (and also `pip3`), not `pip-3.6.4`. That's why you get a `command not found`. – abarnert Mar 27 '18 at 00:54
  • Thanks @abarnert 'sudo pip3 ' install bottle worked instead of pip3.6. Thanks for the response. – Kiran Mar 27 '18 at 00:57
  • Possible duplicate of [pip: dealing with multiple Python versions?](https://stackoverflow.com/questions/2812520/pip-dealing-with-multiple-python-versions) – Farhan Mar 28 '18 at 13:47

1 Answers1

0

The default name for pip for Python version X.Y.Z is not pip-X.Y.Z, but pipX.Y. Some linux distros use different names for their versions, but I believe on Mac, both the python.org Python installer and the Homebrew python package (and you probably have one of those two) use the default names, at least as of 2018.

If you only have one 3.Y.Z, it will probably also be available as pip3, which is convenient.

If you've got different names and are hopelessly confused, but you do know how to run your Python 3 itself, you can always use the -m flag to run pip.

Also, most Mac Python installs don't need sudo. If you don't know whether you do, try it without first. If you get a bunch of permissions errors, then you do need sudo after all, but otherwise, don't use it.

So, what you want is probably any of these:

pip3.6 install bottle
pip3 install bottle
python3 -m pip install bottle
abarnert
  • 354,177
  • 51
  • 601
  • 671