I can run a simple "Hello World" Google App Engine application on localhost with no problems. However, when I add the line "import gdata.auth" to my Python script I get "ImportError: No module named gdata.auth".
I have installed the gdata module and added the following line to my .bashrc:
export PYTHONPATH=$PYTHONPATH:/Library/Python/2.5/site-packages/
Is there anything else I need to do? Thanks.
EDIT: The strange thing is that if I run python from a shell and type "import gdata.auth" I do not get an error.
Your .bashrc is not known to Google App Engine. Make sure the gdata directory (with all its proper contents) is under your application's main directory!
See this article, particularly (and I quote):
To use this library with your Google
App Engine application, simply place
the library source files in your
application's directory, and import
them as you usually would. The source
directories you need to upload with
your application code are src/gdata
and src/atom. Then, be sure to call
the
gdata.alt.appengine.run_on_appengine
function on each instance of a
gdata.service.GDataService object.
There's nothing more to it than that!
The gdata client library installation script installs the modules in the wrong directory for ubuntu python installation.
sudo mv /usr/local/lib/python2.6/dist-packages/* /usr/lib/python2.6/dist-packages
try adding this to your script:
import sys
sys.path.append('<directory where gdata.auth module is saved>')
import gdata.auth
Related
I have two files - one PHP file and one Python file. The python file imports the Jira module, searches for issues, and obtains information from Jira. This file does function correctly and it will find Jira issues and return all needed fields successfully.
The PHP file (for this example, let's call it py_exec.php) is part of a website and executes the Python file through shell_exec; something to the effect of:
$jira_issues = shell_exec(python3 py_search.py issue=blah);
print_r($jira_issues);
When I run the Python script directly, the script works correctly.
When I execute the PHP script directly, which in turn executes the Python script, the script works correctly.
But when I run the PHP script from the website, the script returns nothing.
After troubleshooting a bit, I tried to run the command as the apache user and I am given the following error:
ModuleNotFoundError: No module named 'jira'
Obviously the module is installed, but it seems that it's not accessible to Apache.
How do I make this module accessible to Apache?
Many thanks, in advance, for any help I can get.
su to the apache user and run pip install jira. Check that it worked by doing python and then import jira.
Sometimes pip ends up aliased to something other than python. So if you have issues, try python -m pip instead.
I manually removed /Library/Python/2.7/site-packages/google through terminal (rm), however it still seems I can import the package in python 2.7.
I am able to run import google but when I print google.__path__ it displays ['/Library/Python/2.7/site-packages/google'] even though that directory no longer exists because I deleted it.
I initially deleted this package because it was giving me import errors when trying to run google's app engine api, so I need to have import google be unlinked to this directory.
Any help would be greatly appreciated!
Try starting python in verbose mode. This will show from where packages are imported. Since the output can overflow, write it to a text file.
python -v 2>&1 | tee out.txt
>>import google
>>exit()
Open out.txt and see from where google package is being imported.
As suggested earlier, import issues can be avoided by using virtualenv.
I basically used the install command "$pip install Flask" and when I try to run a program it says "module can't be found." Flask is installed in "/usr/local/lib/python2.7/site-packages" but I thought the point of pip was so I could import these packages everywhere. I'm trying to run a file on my desktop and even when I move the Flask folder to the desktop, it doesn't work. Any advice? Thanks!
This may not directly solve whatever problem you are having with path variables, but one alternative would to download virtualenv
Flask actually has a good tutorial on how to accomplish this here
I am trying to use the dropbox sdk for python. I installed a virtual enviroment and used pip install to install dropbox-sdk. When I try to run the example code (see below) I get a importerror client cannot be found, but if I try to do it from the interactive intreperter it works. So what am I doing wrong. APP key and secret key and acces_type ommitted.
Update: I found the problem, i called my own file dropbox.py and in that file imported dropbox. I accidently imported my own file. Renamed my file and now it works.
My computer says...
"-bash: appcfg.py: command not found"
What is wrong?
I can run my application using google-app-engine-launcher and I have python pre-installed.
I am trying to upload my app using "appcfg.py update myapp"
I am new to Mac development.
In App Engine launcher there is a menu option called "Make Symlinks..." that adds symlinks for the various App Engine utility commands, like appcfg.py.
This is how my path dir looks like: Home/Brice/google_projects/google_appengine
I store both the google_appengine and my google_apps in my google_projects folder
In terminal: (While in my google_projects folder)
upload to localhost:
google_appengine/dev_appserver.py appname
upload to GAE:
google_appengine/appcfg.py update appname
and replace appname with the name of your app folder
Hope that helps!
If someone (like me) comes across this more recently due to appcfg.py and dev_appserver.py still appearing frequently in the documentation:
0.9.68 (2015/07/08)
[...]
The standalone App Engine SDKs are no longer distributed through the Cloud
SDK.
App Engine functionality can still be used through the
gcloud preview app command group.
[...]
If you need to use appcfg or dev_appserver directly, these are still
available in the App Engine SDK downloads that can be found here:
https://cloud.google.com/appengine/downloads
(from google-cloud-sdk/RELEASE_NOTES)
Try: ./appcfg.py
Current dir is usually not part of path.
If is not in a directory specified in the PATH environment variable and marked executable it wont execute by calling its plain name.
when in doubt the following should always work:
python /path/to/appcfg.py <your arguments>
Because the top-voted and accepted answer doesn't explain this, and not everyone will read the comments on it, here's what to do:
Ensure you've installed Google App Engine SDK/Launcher from https://cloud.google.com/appengine/downloads?csw=1
Within it, select the option to "Make Symlinks...". "Make Command Symlinks?" may pop up in a dialog when you open it for the first time or after it's updated itself.
You'll have to do this each time it updates itself or it'll stop working. This is often what's gone wrong.
Using command line there are two options
1. make the two files executable and create symbolic links for them
# chmod +x path/to/google_appengine/dev_appserver.py
# ln -s /path/to/google_appengine/dev_appserver.py /bin
# chmod +x path/to/google_appengine/appcfg.py
# ln -s /path/to/google_appengine/appcfg.py /bin
2. export PATH and PYTHONPATH variables. To do this add following lines in .bashrc file
export PATH=$PATH:/path/to/google_appengine/
export PYTHONPATH="$PYTHONPATH:/path/to/google_appengine:/path/to/google_appengine/lib/:/path/to/google_appengine/lib/yaml/"