nameerror

Creating a decorator / cache for checking global variable

狂风中的少年 提交于 2019-12-25 00:56:42
问题 I've quite a few functions that uses some global variables to hold an object to be reused throughout the library, e.g.: from some.other.lib import Object1, Object2, Object3, Object4, Object5 def function1(input): global _object1 try: _object1 except NameError: _object1 = Object1 return _object1.func1(input) def function2(input): global _object2 try: _object2 except NameError: _object2 = Object2 # Use function1 to do something to the input return _object2.func2(function1(input)) def function3

NameError: name '' is not defined

好久不见. 提交于 2019-12-24 14:43:03
问题 I am trying to make a script in Python that will conjugate Spanish verbs. This is my first time scripting with Python, so it may be a simple mistake. When I run the script, I input "yo tener" and receive an error: Traceback (most recent call last): File "", line 13, in File "", line 1, in NameError: name 'yo' is not defined See more at: http://pythonfiddle.com/#sthash.bqGWCZsu.dpuf # Input pronoun and verb for conjugation. text = raw_input() splitText = text.split(' ') conjugateForm = eval

Rails gives NameError for all command line methods such as generate or rake

浪子不回头ぞ 提交于 2019-12-24 11:29:20
问题 I'm a beginner with Rails and I've been trying to find out what in the world is going wrong here for the past few days but with absolutely no luck. I searched everywhere, but found nothing. Basically, when I run any sort of command line method, I will get a NameError. I have tried running this in different project directories as well that used to work. It seems that rails is just broken... I am running Win7-32bit using NetBeans 6.9.1 for editing files and cmd.exe for running rails console.

ruby: irb gives NameError attempting to use mechanize gem (ubuntu)

拜拜、爱过 提交于 2019-12-24 09:37:18
问题 On my ubuntu box, irb (ruby) gives a NameError when I try to use the mechanize gem: $ irb irb(main):001:0> require 'mechanize' => true irb(main):002:0> Mechanize.new NameError: uninitialized constant Mechanize from (irb):2 from :0 gem env shows this: RubyGems Environment: - RUBYGEMS VERSION: 1.3.7 - RUBY VERSION: 1.8.7 (2010-01-10 patchlevel 249) [x86_64-linux] - INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.8 - RUBY EXECUTABLE: /usr/bin/ruby1.8 - EXECUTABLE DIRECTORY: /usr/bin - RUBYGEMS

Error with global variables are not defined in a thread function on python

半腔热情 提交于 2019-12-24 07:54:13
问题 I'm working in a project with OCR using a webcam. I defined a capture() function for save the frame that contains minimum 20 contours with areas greater than 60 pixels in lapses of 3 seconds. I need that the main while cycle works all the time. So I'm using a thread to call capture() function. When I run the code the Python Shell returned an error: NameError: global name frame, ln2 are not defined . The 13th commented line solves the error for the variable frame . Does it means that I have to

python catching NameError when loading module

旧时模样 提交于 2019-12-24 03:26:18
问题 I'm trying to catch any exceptions that happen when you cannot load a module. The current results are that the "except" block does not get executed. import sys def loadModule(module): try: import module except: print """ Cannot load %s For this script you will need: cx_Oracle: http://cx-oracle.sourceforge.net/ pycrypto: https://www.dlitz.net/software/pycrypto/ paramiko: http://www.lag.net/paramiko/ """ % module sys.exit(1) loadModule(cx_Oracle) Error: Traceback (most recent call last): File "

Error when “import matplotlib.pyplot as plt”

爱⌒轻易说出口 提交于 2019-12-23 10:50:53
问题 I am very new to python. So, my problem might be too simple to be solved. But I cannot. Please help me! I did not have any problem to use "plt", but it suddenly shows error message and does not work, when I import it. Please see the below. >>> import matplotlib >>> import matplotlib.pyplot as plt Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib64/python2.6/site-packages/matplotlib/pyplot.py", line 6, in <module> from matplotlib.figure import Figure,

Django NameError urls.py

你说的曾经没有我的故事 提交于 2019-12-23 03:04:14
问题 Im getting a name error: name sitemaps is not defined from my urls.py when I try to integrate sitemaps with my application. From my urls.py: from django.contrib.sitemaps import Sitemap (r'^sitemap\.xml$', 'django.contrib.sitemaps.views.sitemap', {'sitemaps': sitemaps}), Is there something wrong with this regular expression from my urls.py? Or is there another problem going on? Thanks for your input 回答1: Generally you will do something like this - from django.contrib.sitemaps import Sitemap,

Django NameError urls.py

老子叫甜甜 提交于 2019-12-23 03:03:18
问题 Im getting a name error: name sitemaps is not defined from my urls.py when I try to integrate sitemaps with my application. From my urls.py: from django.contrib.sitemaps import Sitemap (r'^sitemap\.xml$', 'django.contrib.sitemaps.views.sitemap', {'sitemaps': sitemaps}), Is there something wrong with this regular expression from my urls.py? Or is there another problem going on? Thanks for your input 回答1: Generally you will do something like this - from django.contrib.sitemaps import Sitemap,

ActiveAdmin - uninitialized constant AdminUser

人盡茶涼 提交于 2019-12-22 06:09:51
问题 I'm getting an error while trying to run my app, having recently installed ActiveAdmin. It was working fine, but, after idling for a while, suddenly it isn't! In my gem file: gem 'activeadmin' In my routes: devise_for :admin_users, ActiveAdmin::Devise.config ActiveAdmin.routes(self) And in my admin_user.rb ActiveAdmin.register AdminUser do index do column :email column :current_sign_in_at column :last_sign_in_at column :sign_in_count default_actions end etc.... The error when trying to run: