Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't import modules that are there

From command line I can't import appengine, this might be something with my python path:

$ python
Python 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53) 
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from google.appengine.ext import db
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "google/appengine/ext/db/__init__.py", line 98, in <module>
    from google.appengine.api import datastore
  File "google/appengine/api/datastore.py", line 62, in <module>
    from google.appengine.datastore import datastore_query
  File "google/appengine/datastore/datastore_query.py", line 64, in <module>
    from google.appengine.datastore import datastore_index
  File "google/appengine/datastore/datastore_index.py", line 60, in <module>
    from google.appengine.api import validation
  File "google/appengine/api/validation.py", line 51, in <module>
    import yaml
ImportError: No module named yaml
>>> 

I don't want duplicate installations, I want to point the Python interpretor to where the missing module is. How do I make the interpretor find the app engine modules from the command prompt? In the application these imports are working.

like image 668
Niklas Rosencrantz Avatar asked Jan 09 '12 14:01

Niklas Rosencrantz


People also ask

Why can't I import modules in Python?

This is caused by the fact that the version of Python you're running your script with is not configured to search for modules where you've installed them. This happens when you use the wrong installation of pip to install packages.

How do I fix module not found?

To solve the "Module not found: Can't resolve" error in React, make sure to install the package from the error message if it's a third-party package, e.g. npm i somePackage . If you got the error when importing local files, correct your import path.

How do I import an entire module?

You need to use the import keyword along with the desired module name. When interpreter comes across an import statement, it imports the module to your current program. You can use the functions inside a module by using a dot(.) operator along with the module name.


1 Answers

appending:

/usr/local/google_appengine/:/usr/local/google_appengine/lib/:/usr/local/google_appengine/lib/yaml/

to your PYTHONPATH environment variable should do the trick (your SDK location may vary).

like image 57
Wooble Avatar answered Sep 21 '22 05:09

Wooble