Python 3 boxsdk

Highlighted
Occasional Contributor

Python 3 boxsdk

I see others seem to be using python3, but when I install boxsdk using pip, I can only run the little program snippet using python2:

 

i@raspberrypi:~ $ python3 boxInit.py
Traceback (most recent call last):
File "boxInit.py", line 1, in <module>
from boxsdk import OAuth2, Client
ModuleNotFoundError: No module named 'boxsdk'

 

In the past when I've used pip it was pip for python2, and pip3 for python3, but pip3 can't find boxsdk.  So...how do I install boxsdk so that it can be seen by python3?

 

I must be missing something simple since others are using python3.  What is it?

            Tom

Tags (1)
3 REPLIES 3
Highlighted
Box Employee

Re: Python 3 boxsdk

Hi @TPark_RL,

 

The Python SDK will support both Python 2 and 3 out of the box. It could be that the program you're trying to run was written with Python 2.x syntax, but if you write your own Python 3.x scripts with the SDK it'll work. 

 

- Jon

Highlighted
Occasional Contributor

Re: Python 3 boxsdk

Jon -

    Thanks for the reply.  You're probably right, but the script croaks on the first line:

from boxsdk import OAuth2, Client

 

This occurs when I execute it using: "python3 boxInit.py"

If instead I use "python boxInit.py" it doesn't croak, and the user ID gets printed.  

 

boxInit.py is from your documentation:

from boxsdk import OAuth2, Client

auth = OAuth2(
client_id='<my client id>',
client_secret='<my client-secret>',
access_token='<my access token>,
)
client = Client(auth)

user = client.user().get()
print('The current user ID is {0}'.format(user.id))

 

Seems pretty simple.  Any ideas?

           Tom

     

First-time Contributor

Re: Python 3 boxsdk

Hi Team,

I'm seeing the same issue on my local. FYI I have python 3 installed o. my local but for some reason I get "

ModuleNotFoundError: No module named 'boxsdk'" this eeror. Any help is appreciated.

 

Ashish