App Engine Python won't start - python

I don't know what changed, but suddenly none of my Python App Engine projects will start on my PC. They start on my MacBook just fine, so there's something about the installation on my PC that's messed up. I've tried going back to 1.8.8, but that doesn't work. I've also tried using a fresh Python installation, but that didn't work. I've even tried using port 8080 (I usually use port 80, as I run the app launcher as admin).
This is what shows up in the error log when I click start on one of my projects:
2014-02-05 10:42:24 Running command: "['c:\\users\\jonathan\\appdata\\local\\enthought\\canopy\\user\\scripts\\pythonw.exe', 'C:\\Program Files (x86)\\Google\\google_appengine\\dev_appserver.py', '--skip_sdk_update_check=yes', '--port=80', '--admin_port=8000', 'C:\\Users\\jonathan\\My Repositories\\my-project']"
Traceback (most recent call last):
File "C:\Program Files (x86)\Google\google_appengine\dev_appserver.py", line 197, in <module>
_run_file(__file__, globals())
File "C:\Program Files (x86)\Google\google_appengine\dev_appserver.py", line 193, in _run_file
execfile(script_path, globals_)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\devappserver2.py", line 32, in <module>
from google.appengine.tools.devappserver2.admin import admin_server
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\admin\admin_server.py", line 29, in <module>
from google.appengine.tools.devappserver2.admin import console
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\admin\console.py", line 22, in <module>
from google.appengine.tools.devappserver2 import module
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\module.py", line 69, in <module>
from google.appengine.tools.devappserver2 import wsgi_server
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\wsgi_server.py", line 31, in <module>
from cherrypy import wsgiserver
File "C:\Program Files (x86)\Google\google_appengine\lib\cherrypy\cherrypy\__init__.py", line 278, in <module>
_pydoc._builtin_resolve = _pydoc.resolve
AttributeError: 'module' object has no attribute 'resolve'
2014-02-05 10:42:32 (Process exited with code 1)
Also, I'm using Windows 7 x64. My original installation of Python is from Enthought x64, but I did try using the basic x64 Python as well. As mentioned, I downgraded from 1.8.9 to 1.8.8, to no avail.

From a quick Google search, other users are suggesting it's a bug in pyvenv. Since not very many people are still using CherryPy, and it seems to only manifest itself in whatever CherryPy is doing there, that's probably it.
Bug the gist is that somewhere, only on Windows, you have a pydoc.py file which is being imported instead of the standard library's pydoc file.
So, find the offending pydoc.py file in your import path, and rename it. You can most likely find it by doing something like this:
import pydoc
print pydoc.__file__

Related

PyInstaller "You may load I/O plugins with the `skimage.io.use_plugin`"

useing Pyinstaller packages a python script
Pyinstaller version 3.2
OS:Ubuntu
Traceback (most recent call last):
File "<string>", line 57, in <module>
File "<string>", line 29, in feature_extract
File "caffe/io.py", line 295, in load_image
File "skimage/io/_io.py", line 100, in imread
File "skimage/io/manage_plugins.py", line 194, in call_plugin
RuntimeError: No suitable plugin registered for imread.
You may load I/O plugins with the `skimage.io.use_plugin` command. A list of all available plugins can be found using `skimage.io.plugins()`.
file_test returned -1
I have been getting above error. Could some one please tell me how would i fix it?
The problem seems to be related to this github issue, essentially the skimage.io._plugins submodule is making life hard for Pyinstaller.
To make sure everything you need is packaged you should have a hook file that contains
from PyInstaller.utils.hooks import collect_data_files, collect_submodules
datas = collect_data_files("skimage.io._plugins")
hiddenimports = collect_submodules('skimage.io._plugins')
(or if you already have a hook file with these, extend the current datas and hiddenimports).

Can't write to PYTHON_EGG_CACHE from Python cgi script using XAMPP

I have this simple script to connect via ssh to a server and it works if I run the script from shell, but it doesn't when I call the script from cgi-bin (http://localhost/cgi-bin/test.py)
#!C:\Python27\python
print "Content-type: text/html\n\n"
import spur
shell = spur.SshShell(hostname="192.168.1.5", username="user", password="pass", missing_host_key=spur.ssh.MissingHostKey.accept)
result = shell.run(["pwd"])
print result.output
I'm using XAMPP on Windows and I edited the httpd.conf to accept .py files from cgi-bin, infact a simple
#!C:\Python27\python
print "Content-type: text/html\n\n"
print "Test"
works in browser.
The error found in my Apache logs is as follows:
Traceback (most recent call last):
File "C:/xampp/cgi-bin/smart.py", line 4, in <module>
import spur
File "C:\\Python27\\lib\\site-packages\\spur\\__init__.py", line 2, in <module>
from spur.ssh import SshShell
File "C:\\Python27\\lib\\site-packages\\spur\\ssh.py", line 15, in <module>
import paramiko
File "build\\bdist.win32\\egg\\paramiko\\__init__.py", line 30, in <module>
File "build\\bdist.win32\\egg\\paramiko\\transport.py", line 49, in <module>
File "build\\bdist.win32\\egg\\paramiko\\dsskey.py", line 26, in <module>
File "build\\bdist.win32\\egg\\Crypto\\PublicKey\\DSA.py", line 89, in <module>
File "build\\bdist.win32\\egg\\Crypto\\Random\\__init__.py", line 28, in <module>
File "build\\bdist.win32\\egg\\Crypto\\Random\\OSRNG\\__init__.py", line 34, in <module>
File "build\\bdist.win32\\egg\\Crypto\\Random\\OSRNG\\nt.py", line 28, in <module>
File "build\\bdist.win32\\egg\\Crypto\\Random\\OSRNG\\winrandom.py", line 7, in <module>
File "build\\bdist.win32\\egg\\Crypto\\Random\\OSRNG\\winrandom.py", line 4, in __bootstrap__
File "C:\\Python27\\lib\\site-packages\\pkg_resources\\__init__.py", line 1155, in resource_filename
self, resource_name
File "C:\\Python27\\lib\\site-packages\\pkg_resources\\__init__.py", line 1851, in get_resource_filename
self._extract_resource(manager, self._eager_to_zip(name))
File "C:\\Python27\\lib\\site-packages\\pkg_resources\\__init__.py", line 1881, in _extract_resource
self.egg_name, self._parts(zip_path)
File "C:\\Python27\\lib\\site-packages\\pkg_resources\\__init__.py", line 1221, in get_cache_path
self.extraction_error()
File "C:\\Python27\\lib\\site-packages\\pkg_resources\\__init__.py", line 1201, in extraction_error
raise err
pkg_resources.ExtractionError: Can't extract file(s) to egg cache
The following error occurred while trying to extract file(s) to the Python egg
cache:
[Error 5] Accesso negato: 'C:\\\\Windows\\\\Application Data'
The Python egg cache directory is currently set to:
C:\\Windows\\Application Data\\Python-Eggs
Perhaps your account does not have write access to this directory? You can
change the cache directory by setting the PYTHON_EGG_CACHE environment
variable to point to an accessible directory.
Thanks in advance
A place to start would be installing paramiko (and other dependencies, should this error recur) directly into your existing Python installation, such that there's no need for it to be downloaded and extracted as an egg (and thus no need for file permissions appropriate for that task). For instance:
c:\Python\Scripts\easy_install.exe --always-unzip paramiko
Allowing your web server to write to a location where code is stored (and Python eggs are code!) is very bad security practice (on compromise, an attacker could put their own content there, and have it always run when paramiko or other libraries are loaded).

How do I install PDFNet python module?

I have been running in circles trying to figure out how to get my Django app to recognise the trial version of PDFNet:
https://pypi.python.org/pypi/PDFTron-PDFNet-SDK-for-Python/5.7
I tried adding the files to my ~/usr/bin directory, I tried dropping them into my virtualenv's bin directory. Neither has worked. I have read all the documentation i can find. I am too new of a Python developer to look at this package and know how to install it and utilize it in my project.
Please help!
update I attempted to create an app folder, and list this component as an app in the app list, but when I run the code to start the application, I get the following error:
Library not loaded: #rpath/libPDFNetC.dylib
I placed all of the lib files into this folder within my project:
__init.py (empty)
_PDFNetPython.so
libPDFNetC.dylib
PDFNetPython.py
PDFNetRuby.bundle
I used the following import code at the top of the py file I was attempting to use the component on:
import site
site.addsitedir("../pdfnetc")
from pdfnetc.PDFNetPython import *
I put the lib files into a app folder named pdfnetc. once I had this, the import statements were no longer listed as unfound by pycharm.
here is the stack trace:
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 2217, in <module>
globals = debugger.run(setup['file'], None, None)
File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1643, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "/Users/ntregillus/myapp/manage.py", line 12, in <module>
execute_from_command_line(sys.argv)
File "/Users/ntregillus/Envs/myapp/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/Users/ntregillus/Envs/myapp/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute
django.setup()
File "/Users/ntregillus/Envs/myapp/lib/python2.7/site-packages/django/__init__.py", line 21, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Users/ntregillus/Envs/myapp/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/Users/ntregillus/Envs/myapp/lib/python2.7/site-packages/django/apps/config.py", line 202, in import_models
self.models_module = import_module(models_module_name)
File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/Users/ntregillus/myapp/statements/models.py", line 12, in <module>
from statements.managers import StatementTemplateManager, StatementManager
File "/Users/ntregillus/myapp/statements/managers.py", line 8, in <module>
from statements.utils import render_to_pdf, StatementContextBuilder
File "/Users/ntregillus/myapp/statements/utils.py", line 23, in <module>
from pdfnetc.PDFNetPython import *
File "/Users/ntregillus/myapp/pdfnetc/PDFNetPython.py", line 28, in <module>
_PDFNetPython = swig_import_helper()
File "/Users/ntregillus/myapp/pdfnetc/PDFNetPython.py", line 24, in swig_import_helper
_mod = imp.load_module('_PDFNetPython', fp, pathname, description)
ImportError: dlopen(/Users/ntregillus/myapp/pdfnetc/_PDFNetPython.so, 2): Library not loaded: #rpath/libPDFNetC.dylib
Referenced from: /Users/ntregillus/myapp/pdfnetc/_PDFNetPython.so
Reason: image not found
python -m pip install PDFNetPython3
home page link here
Below are steps to install the PDFNet module:
Download the Python and Ruby prebuilt binaries. Make sure you download the right architecture for your Python interpreter.
Extract the downloaded zip file and navigate to it.
Navigate to the /PDFNetC/Lib directory of the Python SDK download and execute:
> chmod a+x fix_rpaths.sh
./fix_rpaths.sh
I am not knowledgable of django, but take a close look at the sample py files that are in the SDK. For example, take a look at PDFNetC/Samples/AddImageTest/PYTHON folder. In there is a .py file, and look at the first 4 lines of code, they indicate what needs to load.
Please note that you need all the files that are in PDFNetC/Lib folder, including the PDFNetC.dll file.
If this does not help, please post the exact (first) error message you get.
It just works fine for me when i try to run the shell script, btw iam using the python as my programming language for pdfnet,
Try to use these commands to run the pdfn
#!/bin/sh
TEST_NAME=PDFATest
export LD_LIBRARY_PATH=../../../PDFNetC/Lib
python -u $TEST_NAME.py
The PDFATest specifies the python code, and then the export will get the required packages such as the PDFNet which is in
../../Lib
folder so make sure you use that file in the lib and then run your code and you will not have any issues with PDFNet, btw i dont answer this with respect to django but sure this will help you out.

Cannot launch Google App Engine on Windows 7

Every time I try to run the GAE Launch, an error occurs and is save in GoogleAppEngineLauncher.exe.log.
I opened it, and found the following:
Traceback (most recent call last):
File "GoogleAppEngineLauncher.py", line 42, in <module>
File "wx\_core.pyc", line 7913, in __init__
File "wx\_core.pyc", line 7487, in _BootstrapApp
File "launcher\app.pyc", line 53, in OnInit
File "launcher\app.pyc", line 98, in _CreateModels
File "launcher\preferences.pyc", line 62, in __init__
File "launcher\platform.pyc", line 435, in PythonCommand
IndexError: list index out of range
What's the problem here?
I am using Python 2.7.6 (64bit).
And the GAP SDK is Windows 1.8.8 - 2013-11-19
I uninstalled the 64 bit version Python and installed 32 bit, and then AppEngine works!
As per the link below, the problem is that you have to have a windows-based Python installation...use an installation that came from an MSI file.
A cygwinny or ortherwise non-windows installation (i.e. just unzipping a python.zip file) will NOT work with Google App Engine.
Gee, thanks Google for making such quality software.
Here's yer link:
https://code.google.com/p/google-appengine-wx-launcher/source/browse/trunk/launcher/platform.py?r=5

Django can't find can't find packages in virtualenv

I'm trying to set up a virtualenv for local development using Google App Engine and django-nonrel. I'm only trying to run the test app provided by django-nonrel for now.
The first time I tried, I got python manage.py runserver to work, but as soon as I tried to fetch a page from localhost:8080, it errored out on me, saying it couldn't find the pdb module:
Traceback (most recent call last):
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 2755, in _HandleRequest
self._Dispatch(dispatcher, self.rfile, outfile, env_dict)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 2643, in _Dispatch
base_env_dict=env_dict)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 682, in Dispatch
base_env_dict=base_env_dict)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 1717, in Dispatch
self._module_dict)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 1619, in ExecuteCGI
reset_modules = exec_py27_handler(config, handler_path, cgi_path, hook)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 1425, in ExecutePy27Handler
import pdb
ImportError: No module named pdb
I tried copying modules from my main Python installation, and I also tried creating a new virtualenv which had access to site-packages. Both approaches worked up to a point - python manage.py runserver ended up not being able to find urllib.
On the other hand, python manage.py shell and then e.g. import pdb or import urrlib (or any other standard library, for that matter) work fine. What am I supposed to do?
The solution: don't use virtualenv at all, and put the libraries you're going to need (such as django) in your project directory. You're going to need that to deploy your app to GAE, anyway.

Categories

Resources