Google app engine fails on OSX Lion with python - python

I am using Google App Engine and just updated to Lion on my mac. I am using eclipse with Pydev. Now as soon as I updated I have been unable to launch the dev server. I get the stack trace below. Anyone else with the same problem?
Traceback (most recent call last):
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/dev_appserver.py", line 76, in <module>
run_file(__file__, globals())
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/dev_appserver.py", line 72, in run_file
execfile(script_path, globals_)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_main.py", line 142, in <module>
import tempfile
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/tempfile.py", line 34, in <module>
from random import Random as _Random
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/random.py", line 45, in <module>
from math import log as _log, exp as _exp, pi as _pi, e as _e, ceil as _ceil
ImportError: dlopen(/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload/math.so, 2): Symbol not found: __PyLong_AsScaledDouble
Referenced from: /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload/math.so

I ended up uninstalling GAE and eclipse and reinstalling. It works now.
From looking at the stack trace it seems like the PyDev plugin was the culprit

I had the same problem, but I just pointed my library stuff to 2.7 in the same root, e.g.
/System/Library/Frameworks/Python.framework/Versions/2.6/...
/System/Library/Frameworks/Python.framework/Versions/2.7/...
and everything worked fine again. Looks like the binaries 2.6 was built on are not compiled for Lion.
Found in Preferences-> PyDev-> Interpreter - Python-> Libraries

Related

Python version error when running the Splunk TA-geoip2 app

I am using Splunk 8+ and Python 3.6. I am trying to run this https://github.com/0x616c6578/TA-geoip2 plugin.
I get this error message when I look into search.log and try to run the Python command in the log by itself:
C:\Users\strozllc>"C:\Program Files\Splunk\bin\Python3.exe" "C:\Program Files\Splunk\etc\apps\TA-geoip2-main\bin\geoip-command.py
Traceback (most recent call last):
File "C:\Program Files\Splunk\etc\apps\TA-geoip2-main\bin\geoip-command.py", line 8, in <module>
from splunklib.searchcommands import \
File "C:\Program Files\Splunk\etc\apps\TA-geoip2-main\bin\..\lib\splunklib\searchcommands\__init__.py", line 145, in <module>
from .environment import *
File "C:\Program Files\Splunk\etc\apps\TA-geoip2-main\bin\..\lib\splunklib\searchcommands\environment.py", line 20, in <module>
from logging.config import fileConfig
File "C:\Program Files\Splunk\Python-3.7\lib\logging\config.py", line 30, in <module>
import logging.handlers
File "C:\Program Files\Splunk\Python-3.7\lib\logging\handlers.py", line 26, in <module>
import logging, socket, os, pickle, struct, time, re
File "C:\Program Files\Splunk\Python-3.7\lib\socket.py", line 49, in <module>
import _socket
ImportError: Module use of python27.dll conflicts with this version of Python
n.
Huh? I looked at line 8 in geocommand.py and it is from
splunklib.searchcommands import \
dispatch, StreamingCommand, Configuration, Option, validators
I look it C:\Program Files\Splunk\bin, and there is indeed a python27.dll. But how is it getting called?
This is a case of Python 3 trying to run Python 2 code. The latest versions of Splunk (you didn't say which one you're using) only support Python 3 so an error will be thrown when an outdated library file is encountered.
I'd suggest filing an issue on GitHub, but the app appears to be abandonware since it hasn't been touched in a year despite having 4 issues.
Consider forking the code and updating it yourself.

Matplotlib with Google App Engine local development server

I want to use matplotlib in my Google App Engine project. I followed the steps, described here in the official docs. What I did:
1) Created a directory named lib in my application root directory.
2) Created a file appengine_config.py in my application root directory and added there these lines:
from google.appengine.ext import vendor
vendor.add('lib')
3) Since the docs say, that the only version of matplotlib working is 1.2.0, I executed the following command in the Terminal:
pip install -t lib matplotlib==1.2.0
There is also step 0 in the docs, which says
Use pip to install the library and the vendor module to enable importing packages from the third-party library directory.
But I don't understand what it actually means. If this is something essential, please, explain to me what it's meant here. I found this answer here on stackoverflow, and It seems there is nothing different from what I have done.
Also, I added
libraries:
- name: matplotlib
version: "1.2.0"
to app.yaml.
So, after all these steps I add the line
import matplotlib
to main.py and start a local server with
python ~/path/google_appengine/dev_appserver.py app.yaml
But when I try to access http://localhost:8080/, the error is raised:
raise ImportError('No module named %s' % fullname)
ImportError: No module named _ctypes
The whole output, if needed, looks like this:
ERROR 2016-08-11 16:26:51,621 wsgi.py:263]
Traceback (most recent call last):
File "/home/magnitofon/Загрузки/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/home/magnitofon/Загрузки/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/home/magnitofon/Загрузки/google_appengine/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "/home/magnitofon/realec-inspector/main.py", line 20, in <module>
import matplotlib
File "/home/magnitofon/realec-inspector/lib/matplotlib/__init__.py", line 151, in <module>
from matplotlib.rcsetup import (defaultParams,
File "/home/magnitofon/realec-inspector/lib/matplotlib/rcsetup.py", line 20, in <module>
from matplotlib.colors import is_color_like
File "/home/magnitofon/realec-inspector/lib/matplotlib/colors.py", line 52, in <module>
import numpy as np
File "/home/magnitofon/Загрузки/google_appengine/google/appengine/tools/devappserver2/python/sandbox.py", line 705, in load_module
module = self._find_and_load_module(fullname, fullname, [module_path])
File "/home/magnitofon/Загрузки/google_appengine/google/appengine/tools/devappserver2/python/sandbox.py", line 446, in _find_and_load_module
return imp.load_module(fullname, source_file, path_name, description)
File "/usr/local/lib/python2.7/dist-packages/numpy/__init__.py", line 180, in <module>
from . import add_newdocs
File "/usr/local/lib/python2.7/dist-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/usr/local/lib/python2.7/dist-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/usr/local/lib/python2.7/dist-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/usr/local/lib/python2.7/dist-packages/numpy/core/__init__.py", line 22, in <module>
from . import _internal # for freeze programs
File "/usr/local/lib/python2.7/dist-packages/numpy/core/_internal.py", line 14, in <module>
import ctypes
File "/usr/lib/python2.7/ctypes/__init__.py", line 10, in <module>
from _ctypes import Union, Structure, Array
File "/home/magnitofon/Загрузки/google_appengine/google/appengine/tools/devappserver2/python/sandbox.py", line 963, in load_module
raise ImportError('No module named %s' % fullname)
ImportError: No module named _ctypes
What am I doing wrong?
matplotlib is one of the Google-provided 3rd party libs, so you should be following just the Requesting a library instructions and
not the Installing a library ones.
Sadly they're now both on the same documentation page, called Using Built-in Libraries in Python 2.7 - very confusing for the unaware as the vendoring technique should be used for libraries which are not GAE built-in/provided. Filed Issue 13202.
Note: pay attention to the Using libraries with the local development server section, it applies to matplotlib. You may need to install some packages on your system, but not in the application itself (which could negatively affect your deployment on GAE) - they need to be accessible by the development server, not directly by your application.
Duh, I just noticed the Using matplotlib section, on the same page :)
It mentions:
Note: The experimental release of matplotlib is not supported on the development server. You can still add matplotlib to the
libraries list, but it will raise an ImportError exception when
imported.
Some searching into this issue surfaced this (old) recipe:
http://code.activestate.com/recipes/578393-gae-matplotlib-demo/
be sure to read the comments.
However I tried, I was not able to make it work. It be this approach just does not work with the current version of the app engine sandbox anymore, or I just was not able to follow all the steps in the recipe correctly.
Maybe an even better read are the comments of Matt Giuca (a google engineer who ported matplotlib to work in GAE production env.) and his pull request in github.
https://github.com/matplotlib/matplotlib/issues/1823/
His comment of April 17, 2013 gives a recipe for matching the dev_appserver (version 1.77) to work with the matplotlib locally.
Maybe this helps someone dealing with this issue.

SQLAlchemy import error : import _mysql

I am new at Python and SQLAlchemy and I was trying to play with them a little bit, but whenever I run a test it gives me the following error :
Traceback (most recent call last):
File "/home/zakaria/workspace-python/Jerreb/essai/tejriba.py", line 11, in <module>
engine = create_engine("mysql://root:root#localhost/python")
File "/usr/local/lib/python2.7/dist-packages/SQLAlchemy-0.9.7-py2.7-linux-i686.egg/sqlalchemy/engine/__init__.py", line 346, in create_engine
return strategy.create(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/SQLAlchemy-0.9.7-py2.7-linux-i686.egg/sqlalchemy/engine/strategies.py", line 74, in create
dbapi = dialect_cls.dbapi(**dbapi_args)
File "/usr/local/lib/python2.7/dist-packages/SQLAlchemy-0.9.7-py2.7-linux-i686.egg/sqlalchemy/connectors/mysqldb.py", line 64, in dbapi
return __import__('MySQLdb')
File "/usr/local/lib/python2.7/dist-packages/MySQL_python-1.2.5-py2.7-linux-i686.egg/MySQLdb/__init__.py", line 19, in <module>
import _mysql
ImportError: /usr/local/lib/python2.7/dist-packages/MySQL_python-1.2.5-py2.7-linux-i686.egg/_mysql.so: undefined symbol: _Py_ZeroStruct
I am working with PyDev.
This is the project architecture:
And these are the libs I have imported :
What is the problem and how can I fix it?
Thanks!
When I got this message, it turned out that, unbeknownst to me, the code was being run in the Python 3 interpreter, instead of Python 2. (This happened because I had installed Ubuntu's libapache2-mod-wsgi-py3 for a different project.) MySQL-python does not yet support Python 3. :'(
I don't know whether WSGI is involved for you, but try making sure you're not running Python 3.

Google app engine does not run local server

My helloworld code doesnt run on google app engine...
I use python 2.7.6 and google app engine version 1.8.8.
Here is what I get:
Traceback (most recent call last):
File "/home/yash/Google/google_appengine/old_dev_appserver.py", line 196, in <module>
run_file(__file__, globals())
File "/home/yash/Google/google_appengine/old_dev_appserver.py", line 192, in run_file
execfile(script_path, globals_)
File "/home/yash/Google/google_appengine/google/appengine/tools/dev_appserver_main.py", line 173, in <module>
from google.appengine.tools import appcfg
File "/home/yash/Google/google_appengine/google/appengine/tools/appcfg.py", line 74, in <module>
from google.appengine.tools import appengine_rpc
File "/home/yash/Google/google_appengine/google/appengine/tools/appengine_rpc.py", line 28, in <module>
import fancy_urllib
File "/home/yash/Google/google_appengine/lib/fancy_urllib/fancy_urllib/__init__.py", line 354, in <module>
class FancyHTTPSHandler(urllib2.HTTPSHandler):
AttributeError: 'module' object has no attribute 'HTTPSHandler'</i>
well...problem solved...i guess few libraries werent installed...compiled python 5-6 times after each library installation...
the problem wasnt in the GAE...it was the lack of required python modules
m still a noob...
Thanks for your time and help :)
Looks like you don't have python support for SSL.
Try this
pip install ssl
Read python-ssl docs for details.
From the docs
If you want to use native python ssl, you must enable it using the
libraries configuration in your application's app.yaml file where you
specify the library name "ssl", as shown here:
libraries:
- name: ssl
version: latest
Does your app.yaml contain this?
Your google appengine environment probably isn't installed properly. I'd recommend reinstalling the SDK and checking for errors in the installation.
If you're using something like virtualenv, it could be affecting the way your install works.

Problems With Aptana Studio (and/or Python) under Lion

After installing Lion, Aptana has stopped working -- I can no longer run any Python code, despite me failing to find any other problems with Python my system. I've tried restoring defaults in Aptana, re-installing and looking for any missing references in Aptana to python components.
Running a simple "hello world" .py script generates a console message:
Traceback (most recent call last):
File "/Applications/Aptana Studio 3/plugins/org.python.pydev.debug_2.2.1.2011073123/pysrc/runfiles.py", line 159, in <module>
main()
File "/Applications/Aptana Studio 3/plugins/org.python.pydev.debug_2.2.1.2011073123/pysrc/runfiles.py", line 25, in main
import pydev_runfiles
File "/Applications/Aptana Studio 3/plugins/org.python.pydev.debug_2.2.1.2011073123/pysrc/pydev_runfiles.py", line 5, in <module>
import pydev_runfiles_unittest
File "/Applications/Aptana Studio 3/plugins/org.python.pydev.debug_2.2.1.2011073123/pysrc/pydev_runfiles_unittest.py", line 6, in <module>
import pydev_runfiles_xml_rpc
File "/Applications/Aptana Studio 3/plugins/org.python.pydev.debug_2.2.1.2011073123/pysrc/pydev_runfiles_xml_rpc.py", line 1, in <module>
from pydev_imports import xmlrpclib
File "/Applications/Aptana Studio 3/plugins/org.python.pydev.debug_2.2.1.2011073123/pysrc/pydev_imports.py", line 14, in <module>
from _pydev_SimpleXMLRPCServer import SimpleXMLRPCServer
File "/Applications/Aptana Studio 3/plugins/org.python.pydev.debug_2.2.1.2011073123/pysrc/_pydev_SimpleXMLRPCServer.py", line 116, in <module>
import BaseHTTPServer
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/BaseHTTPServer.py", line 81, in <module>
import mimetools
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/mimetools.py", line 6, in <module>
import tempfile
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/tempfile.py", line 34, in <module>
from random import Random as _Random
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/random.py", line 45, in <module>
from math import log as _log, exp as _exp, pi as _pi, e as _e, ceil as _ceil
ImportError: dlopen(/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload/math.so, 2): Symbol not found: __PyLong_AsScaledDouble
Referenced from: /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload/math.so
Expected in: flat namespace
in /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload/math.so
Have you tried removing your interpreter and adding it again (that way PyDev would update your PYTHONPATH?
It seems like the problem is that the math.so is not compatible with the latest changes in Lion (so, maybe in the update for Lion it got to 2.7 and you're still with 2.6 in the PYTHONPATH configure in Eclipse?)
For me, a better choice would be using an interpreter downloaded from python.org (where you have more control and don't need to rely on what Mac gives you) and configure the python from python.org.
See: http://pydev.org/manual_101_interpreter.html

Categories