Tuesday, 9 October 2018

Getting requests_oauthlib in python working...

This feels like an important thing to do...

First, check what python version I have

In console, type:

python --version
Answer:

Python 2.7.10

Need to update to Python 3.
Go to:
https://www.python.org/downloads/release/python-370/
Download Python 3.7
And install...

So I can't make that work right now, continue with Python 3.6

So I want to use the library requests_oauthlib

Need to install pip first.
https://stackoverflow.com/questions/49768770/not-able-to-install-python-packages-ssl-tlsv1-alert-protocol-version
Seems to have worked to download pip:
curl https://bootstrap.pypa.io/get-pip.py | sudo python

Now try using pip to download the python library
pip install requests requests_oauthlib

Needed to sudo this to make it work...

Says:
Installing collected packages: oauthlib, idna, certifi, urllib3, chardet, requests, requests-oauthlib

Successfully installed certifi-2018.8.24 chardet-3.0.4 idna-2.7 oauthlib-2.1.0 requests-2.19.1 requests-oauthlib-1.0.0 urllib3-1.23

BUT
how do I make this available to PyCharm?

Well, I found it in

/Library/Python/2.7/site-packages

But I need it to be in...

/Library/Frameworks/Python.framework/Versions/3.6/bin
I think...
let's try copying in console...


Some PyCharm specific stuff:
https://www.jetbrains.com/help/pycharm/2016.1/installing-uninstalling-and-upgrading-packages.html

Want to make the library available in PyCharm...
Select requests and install stuff from there...
I'm a bit confused!!

Close down PyCharm and try again.
Still getting an error message:
ModuleNotFoundError: No module named 'requests_oauthlib'

I've got confused between requests_oauthlib and requests_oauth - a bit annoying...

Copied the library

cp -R /Library/Python/2.7/site-packages/requests_oauthlib /Library/Frameworks/Python.framework/Versions/3.6/bin

Installed with PyCharm

WORKED!!!

Things to learn - with sudo they go to python 2.7 library.
Copying them will work...
Great!!!







No comments:

Post a Comment