Bitly_API on Python 3
There is old version in pip
which doesn't work with Python 3.5. It has problem event with import bitly_api
.
You have to install code from Github: bitly/bitply_api
I use
pip3
andpython3
instead ofpip
andpython
because I have many versions installed.If you don't have
pip3
then you can trypython3 -m pip
Installation
- Test before installing new code.
- Unistall old version.
- Download code from GitHub.
- Install in Python's folder for modules.
- Test after installing new code.
- Remove source code.
.
Test before installing new code.
It shows error ImportError: cannot import name 'Connection'
$ python3
>>> import bitly_api
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/dist-packages/bitly_api/__init__.py", line 1, in <module>
from bitly_api import Connection, BitlyError, Error
ImportError: cannot import name 'Connection'
Unistall old version.
Installation without removing old version may not work.
$ sudo pip3 uninstall bitly_api
Download code from GitHub
using git:
$ git clone https://github.com/bitly/bitly-api-python.git
$ cd bitly-api-python/
using zip:
$ wget https://github.com/bitly/bitly-api-python/archive/master.zip
$ unzip master.zip
$ cd bitly-api-python-master/
(BTW: zip
uses different folder name but it has the same code)
Install in Python's folder for modules
sudo python3 setup.py install
Test after installing new code.
Go to folder without source code to make sure that it doesn't use this source code.
$ cd ..
$ python3
>>> import bitly_api
>>> bitly_api.__file__
'/usr/local/lib/python3.5/dist-packages/bitly_api-0.3-py3.5.egg/bitly_api/__init__.py'
Remove source code.
After installation you can remove source code.
I assume you made cd ..
in previous step.
using git:
$ sudo rm -r bitly-api-python/
using zip:
$ sudo rm -r bitly-api-python-master/
Other information
After downloading but before installing you can test code.
$ export BITLY_ACCESS_TOKEN=your_bitly_access_token_40_chars
$ ./run_tests.sh
.....
----------------------------------------------------------------------
Ran 5 tests in 6.667s
OK
To get "your bitly access token" you have to login to your account on bit.ly and then go to https://bitly.com/a/oauth_apps and generate it
Buy a Coffee