2

I've recently started using Google App Engine with Python, to act as an FCM app server. Before, in tests of FCM, I used PyFCM to handle the messaging, and I've been trying to get it to work with GAE. I followed the instructions here for using third-party Python libraries by vendoring, but it doesn't seem to be working, as I'm getting an ImportError. This is my appengine_config.py:

from google.appengine.ext import vendor
vendor.add('lib')

And this is my code:

from pyfcm import FCMNotification
import time

push_service = FCMNotification(api_key="<my key>")

message = "Hello world! " + str(time.time())
topic = "news"
result = push_service.notify_topic_subscribers(topic_name=topic, message_body=message)

The one thing I can think of that might be the issue is that I had to use sudo to install PyFCM, since I didn't have permission otherwise, and the lib folder which was created by the installation, as well as the PyFCM files, all have a lock icon on them, which I think indicates limited permissions. Is this the problem, or is there something else I need to do?

Edit: All my code is located at the root of my project directory (/home/me/appengine/fcmtest/), and PyFCM is installed in a folder called lib (/home/me/appengine/fcmtest/lib/), also at the root level. This is the traceback of the error:

ERROR    2016-08-02 23:04:32,441 cgi.py:122] Traceback (most recent call last):
  File "/home/me/appengine/fcmtest/job.py", line 1, in <module>
    from pyfcm import FCMNotification
ImportError: No module named pyfcm
Technicolor
  • 1,589
  • 2
  • 17
  • 31
  • You should add the traceback of the error and probably the locations of the pyfcm dir and of the file where the error occurs inside your app's dir structure. – Dan Cornilescu Aug 02 '16 at 22:31
  • as long as the pyfcm dir and its content is readable by a plain user the fact that it's owned by root should not matter. Easy to check: as yourself, not root, open a terminal and execute `ls -alR /home/me/appengine/fcmtest/lib/pyfcm` - if you don't get errors in the "permission denied" category you should be OK. – Dan Cornilescu Aug 02 '16 at 23:56
  • The `pyfcm` dir from the package - does it exist as `.../fcmtest/lib/pyfcm` or as `.../fcmtest/lib/PyFCM/pyfcm`? The former is required for vendoring to work properly, but since you mentioned the lib dir being created by the installation you might actually have the latter. – Dan Cornilescu Aug 07 '16 at 14:25
  • It exists as `/fcmtest/lib/pyfcm`. All the pyfcm code is inside that folder. – Technicolor Aug 14 '16 at 23:12
  • How are you running your code? – Dan Cornilescu Aug 15 '16 at 03:07
  • Another thing to maybe consider - http://stackoverflow.com/questions/37755195/importerror-no-module-named-webapp2-after-linux-sdk-upgrade-1-9-35-1-9-38. Not sure if that only affects importing SDK libs or can affect vendored-in libs as well. – Dan Cornilescu Aug 15 '16 at 13:55

0 Answers0