GAE launcher Python installation can't import module six - python

I just recently launched my local Google App Engine sandbox Python application after not touching it in a while. It seems the following import is giving me problems, but this didn't happen before.
from googleapiclient.discovery import build
This results in the import error:
ImportError: No module named six
I'm not sure what changed with the GAE launcher but it seems the six module is no longer included. I checked on my system and this module is installed globally.

The problem was introduced by some updated libraries included with Google App Engine launcher. To avoid the import error, you'll need to include module six into you project. It can be found here

Related

pytest fails to import module installed via pip and containing underscores

I am used to see import errors of my own modules.
But this time, this is about modules installed via pip and located in site-packages.
Here is a test file expurged from everything but just the imports :
import flask
import pygments
from flask_restful import Resource, Api
#from weather_tool import *
#from flask_restless import *
while running pytest :
Traceback:
test_MonAPPflaskRest.py:3: in <module>
from flask_restful import Resource, Api
E ModuleNotFoundError: No module named 'flask_restful'
Actually, every module with an underscore will fail !!!
flask_restless will fail to import to.
But it work when executed outside of pytest, or simply on the python shell...
Ok, I went through it.
Actually, Anaconda was installed. From here, no problem with that.
I installed Python from source as I'm used to do on a Linux platform and it works normally as expected.
I found out that pytest was not is the list of packages installed via pip.
Seems Anaconda provides a default pytest install. Maybe something is wrong with this version. (which pytest will return a pystest file in the python bin directory.
Actually, a simple pip install pytest in your virtualenv will 'overwrite' this - maybe messy - pytest version.
However calling pytest won't still work. You have to user py.test.
I know this is pretty much empirical. But that's it...
I got a similar error while importing stocker (Unable to find stocker module).
Try adding your 'code directory' to 'sys.path' where python looks for modules and it should be able to import then.
For more details:
https://bic-berkeley.github.io/psych-214-fall-2016/sys_path.html
I used the code:
>>> import sys
>>> sys.path.append('code') # code = the directory where your module is saved
>>> # Now the import will work
>>> import a_module # a_module = the module you are trying to import
I also faced the same issue when installed in virtual environment. I've deactivated virtual environment, installed flask-restful from PIP and then activated virtual environment. The issue is resolved.

Google App Engine ImportError: No module named

I am creating a Python Web App in Google App engine.
When I
sudo pip install
a third party library and then try to import it, I get the error 'ImportError: No module named x'. Where x is the name of that library. In my case as an example: Boto, Boto3, Fask etc.
If I go into shell in GAE and type python >> import X the library can be used inside the python environment. When deploying the app though or running the app in the virtaul server in Google App Engine I get the module import error.
I even tried methods like: python >> import sys >> sys.path.insert(0, "path_here")
export PYTHONPATH and selected where those libraries are located
I even followed several Q&A here in Stackoverflow without any success, can somebody please give me a proper way to fix the import error in Google App Engine?
FYI
I am not using any local environment in my pc, I am working directly through the GAE bash console, the launch code editor in GAE and I am running the command dev_appserver.py $PWD
When I do
pip freeze
I can see that the modules are currently installed and deployed on the GAE virtual environment. Is there a problem with my path? What's the best approach to make GAE load my already installed third party libraries.
UPDATE:
Importing the library directly on the python shell from Google App Engine works just fine. Importing the library on my python app index.py file results in the error.
Python import directly from Shell
Python import to the index.py file
Though this is an old thread, adding this answer now:
Run command : gcloud components list
This will show the different components installed and not in your environment.
Install app-engine-python components if not installed:
gcloud components install app-engine-python
gcloud components install app-engine-python-extras
If it doesn't work:
In Windows, uninstall and download and install Google-sdk (check the python version you need). Delete all the files the installer ask you to delete in the last step and run the gcloud component commands again.

Pip - No module named vimpdb

I'm trying to install the vimpdb lib but it's working, even though I successfully installed vimpdb using pip install I always get this error:
import vimpdb; vimpdb.set_trace();
ImportError: No module named vimpdb
I'm running the code locally but when I run the same code as a simple script (without using localhost) it imports correctly, it only throws an error when I start a server and begin to try using this plugin.
Any ideas?
Thansk!
App Engine won't import Python modules on your Python path. You need to actually include the module within the App Engine project.
For example, in the same directory as app.yaml, you could add a symbolic link similar to this:
vimpdb -> /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/vimpdb
Or you could copy the vimpdb directory to that location.

Packaging a flask application with py2exe

I have a web application which uses Flask(python module) for the backend. I am trying to make it a standalone application using py2exe.
The setup.py code is
from setuptools import setup
import py2exe
setup(console=['app.py'])
While packaging, the command prompt says that some of the modules are missing(missing modules mentioned in the prompt). How do I include those modules. While running this error shows up "No module named message":
Can anybody tell what is that error because of??
Lets say if this .exe file is working properly at the end, I want to distribute this app on other systems. Do they need to install Flask or other modules??
Thanks

Trouble with Python and IntelliJ

I'm writing a Flask application in IntelliJ, and for some reason I can't get IntelliJ to recognize Flask extensions. And so this works just fine:
from flask import Flask, Response, request
But this does not:
from flask.ext.wtf import Form
It will recognize and autocomplete flask.ext but not any submodules.
Does anyone know what the problem could be?
More info:
I'm using virtualenv and installing dependencies via bin/pip install <dependency>.
I'm using the Python 2.7.5 SDK
The modules that I'm trying to get IntelliJ to recognize have all been successfully installed.
PyCharm has difficulty completing flask.ext... because all flask.ext does is proxy imports at runtime, so the built-in static detection is faulty.
For future reference, flask.ext is deprecated in favor of using the actual package import such as from flask_wtf import Form. As of Flask 1.0 it has been removed completely.

Categories