This is using the Python SDK version 1.8.0.
My remote API works fine using remote_api_shell.py, but doesn't work when trying to accessing from within a python script. I'm using the sample code from google:
from google.appengine.ext.remote_api import remote_api_stub
import getpass
def auth_func():
return (raw_input('Username:'), getpass.getpass('Password:'))
remote_api_stub.ConfigureRemoteApi(None, '/_ah/remote_api', auth_func,
'localhost:8080')
and I'm also importing the fix_sys_path() from dev_appserver.py to set my sys.path correctly for the google app engine SDK:
import dev_appserver
dev_appserver.fix_sys_path()
that adds, among other paths, the following line to my sys.path:
'/google_appengine_1.8.0/lib/fancy_urllib'
However, the following error is thrown when the above call to remote_api_stub.ConfigureRemoteApi() is called:
opener.add_handler(fancy_urllib.FancyProxyHandler())
AttributeError: 'module' object has no attribute 'FancyProxyHandler'
Wait 7 years, and it all seems to work fine.
Related
I followed the instructions and successfully installed pypostal python package (package to help parse addresses) https://github.com/openvenues/pypostal.
I'm trying to set this up so the python script can be callable through an apache server on an ubuntu box. It works fine when executing the script from Terminal. However, it doesn't work when I make a call to apache to execute the script and I get the following error in the apache logs. I believe it might be some pathing issue but I haven't had much luck to resolve it. Any ideas will be appreciated.
Error:
File "/var/www/html/cgi-bin/get_parsedAddress.py", line 5, in
from postal.parser import parse_address
ModuleNotFoundError: No module named 'postal'
python script contents:
import sys
from postal.parser import parse_address
addressList = parse_address(sys.argv[1])
print(addressList)
I'm trying to get a Flask app hosted onto an IIS server and I'm stumbling at the last section. Here are the steps I've taken so far:
Installed Python 2.6.6 and Flask 0.10.1
Installed IIS 7.5
Downloaded PyISAPIe 1.1.0
Created a new web site in IIS
Turned on "Enable 32-Bit Applications" for my newly created Application Pool.
Created a Wildcard Script Map using the PyISAPIe .dll
Created the following file and named it 'test.py'
from Http.WSGI import RunWSGI
from Http import Env
from datetime import datetime
from flask import Flask
app = Flask(__name__)
app.debug = True
#app.route('/', defaults={'path': ''})
#app.route('/')
def catch_all(path):
s = "Path: %s\nTime: %s" % (path, datetime.now())
return s
def Request():
RunWSGI(app)
Used Chrome to go to localhost/test.py which returned:
The problem is this: my app only runs if you go to /test.py, but I'd like to run regardless of the URL. What do I need to do within IIS so that all requests, regardless of the URL, will use my flask app?
UPDATE: I've got it working, sort of. Here's what I did:
Replaced the Request function in Http.Isapi.py with the following:
.
app_root = "my path"
sys.path.append(app_root)
from test import Request
Used Chrome to go to localhost/test.py which returned:
I now have a new problem. When I go from my test app to the actual app I am greeted with the following traceback:
File "C:\Python26\Lib\site-packages\sqlalchemy\connectors\pyodbc.py", line 50, in dbapi
return __import__('pyodbc')
ImportError: DLL load failed: The specified module could not be found.
The issue isn't that I don't have pyodbc installed. My app works perfectly fine if it's booted up through the Flask.run() method.
I'm trying to code a program to check files in Google Cloud Storage using Python.
Now I'm read the google doc -> https://developers.google.com/api-client-library/python/start/installation.
At the last step - "App Engine", it asks user to do following:
->> cd myproject
->> unzip google-api-python-client-gae-1.1.zip
So what's the next steps? I'm still having problem to run the Google sample python code about GCS, which throw error:
Traceback (most recent call last):
File "gcs_test.py", line 22, in <module>
from google.appengine.ext import webapp
ImportError: No module named google.appengine.ext
I tried to add below code but still got same error:
from sys import path
path.append(r"C:\Py_dev\gcs_test\google-api-python-client-gae-1.2.zip")
path.append(r"C:\Py_dev\gcs_test\C:\Py_dev\gcs_test\apiclient")
Thanks for all kind help!
google.appengine is the library used by App Engine apps, not by the api client library, the library you are looking for is apiclient
If you wish to run a normal python script instead of an App Engine app, you should remove references to App Engine specific libraries.
If you are running an app engine app, make sure you are using dev_appserver.py or the actual app engine servers, not just running the script using python
I am trying to parse an RSS feed with feedparser. The below code snipped is cut-short for brevity
from google.appengine.api import urlfetch
import feedparser
print 'Content-Type: text/plain'
feed_url = 'http://parsethisurl'
feedinput = urlfetch.fetch(feed_url)
rss_parsed = feedparser.parse(feedinput.content)
......
#some logic here
.........
print "\n".join(episode_info) # printing out the desired output.
works fine on my python interpreter but when I add my application to gapp engine launcher and try to run it via localhost:10000 it gives me the following error
<type 'exceptions.ImportError'>: No module named feedparser
args = ('No module named feedparser',)
message = 'No module named feedparser'
feedparser module is already installed on my system.
>>> sys.version
'2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)]'
>>> import feedparser
>>>
I read some articles on stackoveflow and blogs that feedparser doesn't work directly on gapp engine. I followed the advice and used urlfetch.fetch(feed_url) but than also I am getting an error.
PS: PythonPath on gapp launcher is C:\Python25\python.exe
You have feedparser installed locally, so when you run your application on development server it works. But in order to use feedparser on production you need to include it in your project, because GAE do not provide this library for you.
You need to upload feedparser along with your project files. For this you can copy it into your application root directory and then deploy your application.
I am getting this error when running the app in production. It works fine in my local environment. But, after I upload to server, it throws this exception.
The test_handler module exists in test package (and it works fine in local). I believe that the entire folder structure will be uploaded to the server, when we upload.
Also, is there a way to see the entire folder structure in the Google Application Account online?
============================================================================
<type 'exceptions.ImportError'>: cannot import name test_handler
Traceback (most recent call last):
File "/base/data/home/apps/mad-scribe/1.346944987034829366/url_handler.py", line 15, in <module>
from test import test_handler
You can now download the source if you were the developer who uploaded it.
This should give you a concrete understanding of what was uploaded.
AppEngine Docs: Downloading Source Code
The issue was with the package name. I named the package as 'test', which might have stepped on the shoes of some other package.
from test import test_handler
Renaming the package name (test -> test_handlers) fixed the issue.
Thanks to all who responded to this question.