Tipfy nosetest ImportError: No module named fancy_urllib

I try to run nosetest using the tipfy and google utility, but I keep getting the import error:

From the google_appengine directory, I execute the following command (the directory contains dev_appserver.py):

nosetests /Users/me/Documents/python/project/ --with-gae --without-sandbox 

but I get the following error:

 Traceback (most recent call last): File "/usr/local/bin/nosetests", line 8, in <module> load_entry_point('nose==0.11.4', 'console_scripts', 'nosetests')() File "/Library/Python/2.6/site-packages/nose-0.11.4-py2.6.egg/nose/core.py", line 117, in __init__ **extra_args) File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/unittest.py", line 816, in __init__ self.parseArgs(argv) File "/Library/Python/2.6/site-packages/nose-0.11.4-py2.6.egg/nose/core.py", line 134, in parseArgs self.config.configure(argv, doc=self.usage()) File "/Library/Python/2.6/site-packages/nose-0.11.4-py2.6.egg/nose/config.py", line 323, in configure self.plugins.configure(options, self) File "/Library/Python/2.6/site-packages/nose-0.11.4-py2.6.egg/nose/plugins/manager.py", line 270, in configure cfg(options, config) File "/Library/Python/2.6/site-packages/nose-0.11.4-py2.6.egg/nose/plugins/manager.py", line 93, in __call__ return self.call(*arg, **kw) File "/Library/Python/2.6/site-packages/nose-0.11.4-py2.6.egg/nose/plugins/manager.py", line 161, in simple result = meth(*arg, **kw) File "build/bdist.macosx-10.6-universal/egg/nosegae.py", line 84, in configure File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver.py", line 51, in <module> import fancy_urllib ImportError: No module named fancy_urllib 

I can download the tipfy hello_world project without any errors, and I have other application engine projects on the same computer, everything works fine.

Using mac os x 10.6.6 and I have nose and noses installed. I also tried to execute the same command from the / Users / me / Documents / python / project / folder, but I get the same result

+4
source share
6 answers

I had the same problem and here is my quick solution:

Edit this file "/usr/local/bin/dev_appserver.py"

 ...... if version_tuple == (2, 4): sys.stderr.write('Warning: Python 2.4 is not supported; this program may ' 'break. Please use version 2.5 or greater.\n') #Start Change #DIR_PATH = os.path.abspath(os.path.dirname(os.path.realpath(__file__))) DIR_PATH = "/usr/local/google_appengine" #End Change SCRIPT_DIR = os.path.join(DIR_PATH, 'google', 'appengine', 'tools') ...... 

Works for me so far.

+3
source

Try to launch it using the option:

 --gae-lib-root=/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine 

and please show Python sys.path.

+1
source

I also ran into this problem using Nose / NoseGAE. I was not lucky with the various values ​​of --gae-lib-root , but in the end I had the luck fix dev_appserver.py (located in /usr/local/google_appengine/google/appengine/tools/ in my MacOS installation) as follows:

 ... try: import distutils.util except ImportError: pass # ----- start of new code ----- import os, sys DIR_PATH = '/usr/local/google_appengine' EXTRA_PATHS = [ DIR_PATH, os.path.join(DIR_PATH, 'lib', 'antlr3'), os.path.join(DIR_PATH, 'lib', 'django_0_96'), os.path.join(DIR_PATH, 'lib', 'fancy_urllib'), os.path.join(DIR_PATH, 'lib', 'ipaddr'), os.path.join(DIR_PATH, 'lib', 'webob'), os.path.join(DIR_PATH, 'lib', 'yaml', 'lib'), os.path.join(DIR_PATH, 'lib', 'simplejson'), os.path.join(DIR_PATH, 'lib', 'graphy'), ] sys.path = EXTRA_PATHS + sys.path # ----- end of new code ----- import dummy_thread ... 

This follows some code in appcfg.py ( fix_sys_paths() ) mentioned in GAE Problem Ticket No. 3597 . I suspect the problem is how the Nose sets the path, although I still can’t prove it.

0
source

It turns out this is due to a UI error when you set up the "Python Path" in the settings of GoogleAppengineLuncher. To confirm the settings, enter Enter:

  sudo port install python2.7 

Then set the "Python Path" to

  /opt/local/bin/python2.7 

Enter to confirm

See here

0
source

If you use stand-alone scripts, then before using any application associated with the application, you need to connect to dirs

 import sys sys.path.append('/usr/local/google_appengine/') sys.path.append('/usr/local/google_appengine/lib') sys.path.append('/usr/local/google_appengine/lib/yaml/lib/') if 'google' in sys.modules: del sys.modules['google'] 
0
source

Currently (2016) GAE Python recommends loading project libraries into a file at the root level called "appengine_config.py".

Thus, if you are still facing some unpleasant problems, pls be sure to add the os dir path to load the lib library folder (as seen from my code below):

 """`appengine_config` gets loaded when starting a new application instance.""" import os from google.appengine.ext import vendor # insert `lib` as a site directory so our `main` module can load # third-party libraries, and override built-ins with newer # versions. vendor.add(os.path.join(os.path.dirname(__file__), 'lib')) 

After I did this, I was able to successfully run my tests with IntelliJ (PyCharm). Also, pay attention to setting test parameters on intelliJ (PyCharm)

IDE Settings

We hope that the above can help some GAE Python developers as I am having trouble simplifying NoseGAE's work. Be careful!

0
source

Source: https://habr.com/ru/post/1342504/


All Articles