1

Can somebody help me out with why this is happening? I have a python 3, virtualenv based environment, and I am writing some scripts with Facebook SDK.

When I write print statement before importing facebook, the print is happening only once.

Print only once!

When I write print statement after importing facebook, the print is happening twice, even though the print is written only once.

Print twice!

aksappy
  • 3,400
  • 3
  • 23
  • 49
  • 1
    If you had tried to do **anything else**, you would have met [this error instead](https://stackoverflow.com/questions/36250353/importing-installed-package-from-script-raises-attributeerror-module-has-no-at) – Antti Haapala -- Слава Україні Jul 25 '17 at 13:16
  • 1
    Possible duplicate of [Importing installed package from script raises "AttributeError: module has no attribute" or "ImportError: cannot import name"](https://stackoverflow.com/questions/36250353/importing-installed-package-from-script-raises-attributeerror-module-has-no-at) – Foon Jul 25 '17 at 14:13

2 Answers2

3

Rename your file from facebook.py to something else. As it is, it is importing itself rather than the module.

Błotosmętek
  • 12,717
  • 19
  • 29
1

You are not importing facebook sdk library but instead import your own facebook.py file (which prints out date)

SOLUTION: change your facebook.py filename to something else.

TIP: try to avoid file naming that might cause conflicts with other libraries

Povilas
  • 627
  • 2
  • 6
  • 19