Reputation: 1084
I installed oauth2 by just downloading tar.gz package and doing python setup.py install
. However I'm getting this error
bash-3.2$ python
Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import oauth2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named oauth2
>>>
The path to oauth2 is in PYTHONPATH (so that shouldn't be the issue) as I added this line to ~/.bashrc:
PYTHOHPATH=$PYTHONPATH:/Users/me/Downloads/oauth2-1.5.211/
However, when I do this:
bash-3.2$ cd /System/Library/Frameworks/Python.framework/Versions/2.7/
bash-3.2$ ls
Extras Headers Mac Python Resources _CodeSignature bin include lib
bash-3.2$ Python
Python 2.7.1 (r271:86882M, Nov 30 2010, 09:39:13)
[GCC 4.0.1 (Apple Inc. build 5494)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import oauth2
>>>
it works just fine. Any idea how I should install oauth2 to avoid ImportError from python
?
P/S: this is the simlink for python
command
python -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
Upvotes: 2
Views: 9466
Reputation: 21839
I don't have an answer, but I have some general suggestions:
Run python setup.py install
with the same python that you intend to use it from (in your case one is capitalised, the other is not).
I always export
my bashrc variables to ensure they are global, but I am not sure that is your issue here.
When running scripts in the pwd, always run them with ./
. In your case run python as ./Python
to have confidence that you are running the executable you think you are running.
Check your spelling of PYTHONPATH. If you think you have it right, do import sys; print('\n'.join(sys.path))
from within your python session and ensure that the appropriate directory is there
Upvotes: 1
Reputation: 6356
it looks like you have two different versions of python installed, and one of them you launched using Python as opposed to python.
Since your second example workd, it looks like you've installed oauth2 using Python.
Upvotes: 0