i have installed pexpect with the following command "python setup.py install" but when i try to run a program it says "AttributeError: 'module' object has no attribute 'spawn'". how to settle the matter?
Hello all,
I am trying to import NLTK in my python code and I get this error:
Traceback (most recent call last):
File "/home/afs/NetBeansProjects/NER/getNE_followers.py", line 7, in
import nltk
ImportError: No module named nltk
I am using NetBeans: 6.7.1, Python 2.6 NLTK.
My NLTK module is installed in /usr/local/lib/python2.6/dist-packages/nltk/ and I have added this in Python paths in Netbeans.
What am I missing here?
Thanks in advance.
I am using Django and Postgresql as my DBMS.
I wish to set a setting that enables to enable/disable database connection. When the connection is set to closed (in settings.py) the site will display a message such as "meintanence mode" or something like that. Django will not show any db connection error message (or mail them to admins). It is appreciated if django do not try to connect to the database at all.
Hi, I'm a newbie in python.
I want to write a simple web that prints the client ip on screen
my http.conf Handler:
AddHandler mod_python .py
PythonHandler mod_python.publisher
PythonDebug On
The cgi.escape(os.environ["REMOTE_ADDR"]) return this error: KeyError: 'REMOTE_ADDR'
and I just get lost with the BaseHTTPRequestHandler
so what is the simple way to get the client ip?
thank you.
I have looked into Geopy and googlemaps (http://py-googlemaps.sourceforge.net/) and they both do not work for Chinese addresses. My app is stored on the Google App Engine. What I want to do is to parse a file containing addresses of restaurants in Hong Kong, and then Geocode the addresses and store the Lat and Lng in the datastore. How do I do this?
I want to extend some locale-specific features of a python application named OpenERP. All I need is implementing a third party module.function that would be called every time OpenERP calls locale.setlocale() function without changing neither OpenERP nor locale module source code.
The only way I can imagine is provide a module named locale.py inside main application package dir, but It seems that is an unpythonic workaround.
i can't Deploy data on gae , so i use this "appcfg.py rollback myapp/"
but ,it is not useful this time ,and the error is :
urllib2.URLError: <urlopen error (10054, 'Connection reset by peer')>
what should i do ,
thanks
Hi,
im trying to create a script that opens a file and replace every 'hola' with 'hello'.
f=open("kk.txt","w")
for line in f:
if "hola" in line:
line=line.replace('hola','hello')
f.close()
But im getting this error:
Traceback (most recent call last):
File "prueba.py", line 3, in
for line in f: IOError: [Errno 9] Bad file descriptor
Any idea?
Javi
I set a variable MAX_REQUEST = 100 in settings.py
I write a middleware which may lower this value for request origining from a proxy ip address by the following code:
settings.MAX_REQUEST = 10
However, looks like the above modification affects all legitimate users.
Is it normal?
I'm trying to install the Python Imaging Library on Mac OS X 10.4, but I get errors. I'm not sure where the error starts, it's just a huge wall of text when executing sudo python setup.py install.
But the last few lines are:
...
collect2: ld returned 1 exit status
lipo: can't open input file: /var/tmp//ccNKvQpP.out (No such file or directory)
error: command 'gcc' failed with exit status 1
I've googled, but none of the results are working.
hey guys, im trying to run a python script after every 5 minutes using cron, inside the script is a django import
import django
when running the crontab i get mailed the following error
ImportError: No module named django
this is what the crontab file looks like:
[email protected]
*/5 * * * * /usr/bin/python /Users/paulo/Desktop/ashtanga/ping/sender.py
do anyone of you know whats causing this ?
btw i do have django insalled version 1.2, python 2.6, and MacOX 10.6
Is there a disadvantage to using a dynamic Python file to generate the CSS for a webpage? I'd like computers with an administrator cookie to show special admin panel CSS, and show regular CSS for all other users. I'm planning to use:
<link rel="stylesheet" href="/css.py" type="text/css" />
I've just recently switched over to using 64-bit Python 2.6.1 on Mac OS X 10.6 (Snow Leopard). IPython won't work with Django anymore, but IPython works from the command-line.
The error says:
shell = IPython.Shell.IPShell(argv=[])
AttributeError: 'module' object has no attribute 'Shell'
I could use the ./manage.py --plain option, but it's not really a fix. Any help very gratefully received!
I have a Python script that reads through a text csv file and creates a playlist file. However I can only do one at a time, like:
python playlist.py foo.csv foolist.txt
However, I have a directory of files that need to be made into a playlist, with different names, and sometimes a different number of files.
So far I have looked at creating a txt file with a list of all the names of the file in the directory, then loop through each line of that, however I know there must be an easier way to do it.
In Komodo Edit, if I name the file *.django.html it gives me django syntax highlighting BUT it also indents with a tab character (8 spaces) instead of giving me the usual 4 space indent. How can I fix this?
I've tried changing the value in Edit Preferences Editor Indentation Language Settings, but that seems to have no effect on it.
The indentation works as normal (4 spaces) if I'm using any other extension (.py, .html, etc.).
Ideas?
I ran the code to create the generically related objects from this demo:
http://www.djangoproject.com/documentation/models/generic_relations/
Everything is good intially:
>>> bacon.tags.create(tag="fatty")
<TaggedItem: fatty>
>>> tag, newtag = bacon.tags.get_or_create(tag="fatty")
>>> tag
<TaggedItem: fatty>
>>> newtag
False
But then the use case that I'm interested in for my app:
>>> tag, newtag = bacon.tags.get_or_create(tag="wholesome")
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/local/lib/python2.6/dist-packages/django/db/models/manager.py", line 123, in get_or_create
return self.get_query_set().get_or_create(**kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/db/models/query.py", line 343, in get_or_create
raise e
IntegrityError: app_taggeditem.content_type_id may not be NULL
I tried a bunch of random things after looking at other code:
>>> tag, newtag = bacon.tags.get_or_create(tag="wholesome", content_type=TaggedItem)
ValueError: Cannot assign "<class 'generics.app.models.TaggedItem'>": "TaggedItem.content_type" must be a "ContentType" instance.
or:
>>> tag, newtag = bacon.tags.get_or_create(tag="wholesome", content_type=TaggedItem.content_type)
InterfaceError: Error binding parameter 3 - probably unsupported type.
etc.
I'm sure somebody can give me the correct syntax, but the real problem here is that I have no idea what is going on. I have developed in strongly typed languages for over ten years (x86 assembly, C++ and C#) but am new to Python. I find it really difficult to follow what is going on in Python when things like this break.
In the languages I mentioned previously it's fairly straightforward to figure things like this out -- check the method signature and check your parameters. Looking at the Django documentation for half an hour left me just as lost. Looking at the source for get_or_create(self, **kwargs) didn't help either since there is no method signature and the code appears very generic. A next step would be to debug the method and try to figure out what is happening, but this seems a bit extreme...
I seem to be missing some fundamental operating principle here... what is it? How do I resolve issues like this on my own in the future?
I have a script that I want to exit early under some condition:
if not "id" in dir():
print "id not set, cannot continue"
# exit here!
# otherwise continue with the rest of the script...
print "alright..."
[ more code ]
I run this script using execfile("foo.py") from the Python interactive prompt and I would like the script to exit going back to the command line. How do I do this? If I use sys.exit(), the Python interpreter exits completely.
I periodically get this problem where all of a sudden mako is using old versions of templates, and it's not until I manually go and update the template files that they'll use the current version. I'm using
./manage.py runserver
I think it's usually after I update using source control, but it's intermittent, and I can't reliably reproduce the problem.
I found a command a couple of months ago that made my bash history auto-complete on what's already on the line when pressing the up arrow:
$ vim fi
Press ?
$ vim file.py
I'd like to set this up on my new computer, because it saves a lot of time when keeping a big history. The problem is that I can't for the life of me remember where it was mentioned and reading through endless bash references and tutorials unfortunately didn't help either.
Does anybody know the command?
I'm trying to ping an ip address and telnet to some port from an app hosted on app engine. I've tried using http://svn.pylucid.net/pylucid/CodeSnippets/ping.py but for some reason it failing
Thanks
I'm calling python -m pdb myapp.py, when an exception fires, and I'd normally be thrown back to the pdb interpreter to investigate the problem. However this exception is being thrown after I've called through curses.wrapper() and entered curses mode, rendering the pdb interpreter useless. How can I work around this?
Each time I added some strings to a Django string, I run "django-admin.py makemessages -all" to generate .PO files for all locales.
The problem is even I only added 5 news strings, the makemessages command will make 50 strings as fuzzy in .PO files which brings a lot of extra work for our locale maintainers.
This also makes the entire i18n unusable before they manually revise those fuzzy strings.
Hello
I have a problem with django translations.
Problem 1 - i updated string in django.po file, but the change does not appear on the webpage.
Problem 2 - i have created my own locale file with django-admin.py makemessages -l et, added the translation string into file, but they too do not appear on the page.
I do not think this is setting problem, because the translations from django.po file do appear on the website, its just the changes and the translations from my own generated file that do not appear.
Alan
I had Ubuntu 8.10. I upgrade it to 9.04.
I have Openerp5.0 , server/client/web. It worked on 8.10 but not with 9.04.
Now when I try to launch my server using:
./openerp-server.py
I have this error:
ERROR: Import xpath module
ERROR: Try to install the old python-xml package
It seems that this version of openerp doesn't work with python2.6.
Can you help me to redirect openerp to use old version of python please?
I'm prototyping an idea for a website that will use the HTML5 offline application cache for certain purposes. The website will be built with Python and Flask and that's where my main problem comes from: I'm working with those two for the first time, so I'm having a hard time getting the manifest file to work as expected.
The issue is that I'm getting 404's from the static files included in the manifest file. The manifest itself seems to be downloaded correctly, but the files that it points to are not. This is what is spit out in the console when loading the page:
Creating Application Cache with manifest http://127.0.0.1:5000/static/manifest.appcache offline-app:1
Application Cache Checking event offline-app:1
Application Cache Downloading event offline-app:1
Application Cache Progress event (0 of 2) http://127.0.0.1:5000/style.css offline-app:1
Application Cache Error event: Resource fetch failed (404) http://127.0.0.1:5000/style.css
The error is in the last line.
When the appcache fails even once, it stops the process completely and the offline cache doesn't work.
This is how my files are structured:
sandbox
offline-app
offline-app.py
static
manifest.appcache
script.js
style.css
templates
offline-app.html
This is the content of offline-app.py:
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/offline-app')
def offline_app():
return render_template('offline-app.html')
if __name__ == '__main__':
app.run(host='0.0.0.0', debug=True)
This is what I have in offline-app.html:
<!DOCTYPE html>
<html manifest="{{ url_for('static', filename='manifest.appcache') }}">
<head>
<title>Offline App Sandbox - main page</title>
</head>
<body>
<h1>Welcome to the main page for the Offline App Sandbox!</h1>
<p>Some placeholder text</p>
</body>
</html>
This is my manifest.appcache file:
CACHE MANIFEST
/style.css
/script.js
I've tried having the manifest file in all different ways I could think of:
CACHE MANIFEST
/static/style.css
/static/script.js
or
CACHE MANIFEST
/offline-app/static/style.css
/offline-app/static/script.js
None of these worked. The same error was returned every time.
I'm certain the issue here is how the server is serving up the files listed in the manifest. Those files are probably being looked up in the wrong place, I guess. I either should place them somewhere else or I need something different in the cache manifest, but I have no idea what. I couldn't find anything online about having HTML5 offline applications with Flask.
Is anyone able to help me out?