A simple check if the Dropbox API works, I have below dropbox.py script created
import dropbox
dbx = dropbox.Dropbox('MY_TOKEN')
dbx.users_get_current_account()
Running it in normal script mode using terminal, I have to use below command.
username$ python3 dropbox.py
This returns below error:
Traceback (most recent call last):
File "dropbox.py", line 1, in <module>
import dropbox
It works okay when using the interactive mode with below command
username$ python3
Python 3.6.4 (default, Jan 6 2018, 11:51:15)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import dropbox
>>> dbx = dropbox.Dropbox('MY_TOKEN')
>>> dbx.users_get_current_account()
FullAccount displayed here successfully
Why is there a difference in interactive versus script mode? How to get the script mode working?
Probably, the issue is name clutch between your file dropbox.py
and module.
When running dropbox.Dropbox
, python tries to create instance of Dropbox
class from your file (which is treated as module too), and you have no such.
The motivation behind this order of imports is ability to "override" pre-installed modules with your own.
TL;DR: renaming your file should help.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.