appcfg.py command not found - python

I am following the How to set up AppEngineBackend Tutorial on this website https://cloud.google.com/resources/articles/how-to-build-mobile-app-with-app-engine-backend-tutorial
My current environment is:
1.Windows 8(64-bit).
2.Java 7
3.Eclipse 4.2 with ADT(Its the eclipse that is preconfigured with ADT downloaded from the Android Website)
I have had many problems relating to Java, invalid AppEngine SDK, etc. ever since I have started this tutorial. I resolved many of them and have come to the point where data needs to be uploaded to AppEngine datastore from a .csv file using a script in an upload_data.sh file using the following command :
./upload_data.sh places.csv Place
The contents of upload_data.sh are:
!/bin/sh
appcfg.py upload_data
--config_file bulkloader.yaml --url="http://localhost:8888/remote_api" --filename $1 --kind=$2 -e
nobody#nowhere.com
Now the problem is that Windows does not support the .sh files. Also the file contains commands such as appcfg.py, --config_file,etc. For running the .sh file I downloaded Cygwin. Then I installed Python33 and also set the PythonPath environment variable to c:\python33. When I run the above command from Cygwin terminal I get the following:
./upload_data.sh: line 2: appcfg.py: command not found
./upload_data.sh: line 3: --config_file: command not found
./upload_data.sh: line 4: nobody#nowhere.com: command not found
Do I need to tell Cygwin about my python location ? If yes then how to do it?
Also I installed Python and Cygwin much later after I installed Google AppEngine SDK.Is this causing the problem?Are Cygwin and Python supposed to be installed before AppEngine SDK?Does installation of AppEngine SDK automatically inform Cygwin about appcfg.py,etc.?

Although it's not listed as a prerequisite, installing the Google App Engine SDK for Python (available at Google's App Engine SDK Download page) makes appcfg.py available to the command line.
During the installation of this SDK on a Mac, the installation puts appcfg.py on the PATH, thereby solving the "appcfg.py: command not found" error message. This may be similar for Windows.
Additionally, remove the line breaks (i.e., the "Next line" space) that occurs before the --config_file and nobody#nowhere.com words - the script only needs to be a single continuous line without any line breaks (the line should only overflow to the next line due to reaching the edge of the editor).

Here is a simple work around.There's no need to create a shell or .bat file. This should work for anyone and for any operating system using the terminal or command prompt. Your local server should be running in debug mode or in other words you can successfully navigate to http://localhost:8888/_ah/admin
Make sure you have downloaded and extracted Google App Engine SDK for Python to any location on your computer because the appcfg.py file is located in the parent directory extracted.
Put the following files "bulkloader.yaml and places.csv" in the parent folder extracted in step1 i.e. in the same directory where the appcfg.py file is located.
Run the following command directly in the terminal or command prompt:
python appcfg.py upload_data --config_file bulkloader.yaml --url=http://localhost:8888/remote_api --filename places.csv --kind=Place -e nobody#nowhere.com
Press enter when password prompt appears.. Enjoy!!!. Also you might need to wait for about a minute or two sometimes to confirm if the data is available from the datastore viewer.

The simplest solution (in my mind) to your question is to create a .bat file with following content:
python appcfg.py upload_data --config_file bulkloader.yaml --url="http://localhost:8888/remote_api" --filename $1 --kind=$2 -e nobody#nowhere.com
I haven't tested it so it might not work. Don't have a windows machine now. You'll need to put the folder of python.exe in your PATH environment variable.
Please use python 2.7 instead of python 3.3. I'm pretty sure Google App Engine doesn't support any Python 3.x yet.
Cheers

I also got this error on my Mac. It seems the newest version of Google App Engine not include appcfg.py in $PATH by default. The directory includes appcfg.py on my mac is $HOME/google-cloud-sdk/platform/google_appengine/, you can just add this directory in your $PATH and it should work.

If the reason you are searching for this fix is to error in appengine deployment since it states that another deploy is in progress and your app is built with maven, the easier way to rollback is to point your terminal to the directory from where you run the appengine deployments, and type $appengine:rollback.

I know the question is far from the past, but pay attention that appcfg.py is deprecated
Now you should use gcloud commands - https://cloud.google.com/appengine/docs/standard/java/tools/migrating-from-appcfg-to-gcloud

Related

dev_appserver.py does nothing in CMD on windows

I installed python and google cloud sdk. I'm trying to use:
dev_appserver.py app.yaml
When I go to my directory with my web app (using cd [directory]) and enter dev_appserver.py app.yaml into the command line nothing happens. The prompt shows the next line in CMD like I didn't enter anything... I indeed have an app.yaml file and this works perfectly on my MacBook running a local server.
I also tried just typing "dev_appserver.py" and hitting enter and again nothing happens... It's as if I were to press enter in the command line without typing anything.
On MacBook when I type dev_appsever.py without pointing to an app.yaml file - it at least shows me all the potential commands associated with dev_appserver.py. Why doesn't the windows command prompt seem to understand this command? Nor tell me it doesn't understand it? Please help!!! I really want to run a local server for cloud engine on my Windows machine, but have no idea what's wrong. I google'd a bunch and haven't found someone else with this issue...
Finally solved my issue.... turns out goodle cloud sdk requires python 2.7. I uninstalled python 3.8, installed python 2.7. dev_appserver then didn't run unless I went into the folder where it exists:
user/name/local/google/cloudsdk/bin
And then I run python dev_appserver.py and it works.
I also had to make sure my python command worked by adding it into my path. Python3.8 makes it easy to do via install wizard, but 2.7 requires you to go into your environment vars yourself to add it. This is why my python command originally did nothing.
Not related - but my Blender 2.81 stopped working after this. I found out blender requires Python3. So I installed Python3.8 again and got both cloud sdk and blender working. Took way too many hours to solve this.... damn...
It is possible that Windows has files with ".py" mapped to something unexpected. I would suggest specifying the full path to the version of Python you want and pass "dev_appserver.py" as a parameter. Like:
c:\python\python.exe dev_appserver.py app.yaml

Python where do I run this from?

I'm trying to use clarifai with python, I've installed the package using pip, but then it says (here) to get started by configuration as follows.
Configuration
The client uses CLARIFAI_APP_ID and CLARIFAI_APP_SECRET for authentication and token generation. You can get those values from https://developer.clarifai.com and then run:
$ clarifai config
CLARIFAI_APP_ID: []: ************************************YQEd
CLARIFAI_APP_SECRET: []: ************************************gCqT
The config will be stored under ~/.clarifai/config for client's use
But I do not understand where I "run" this from and do i need the "$". I've tried running it from python command prompt and windows command terminal but it just gives errors.
I have a Python27/scripts folder, in this I have a file caled 'clarifai' but with unknow extension i.e. I dont know if its a .py file or .exe file, I have no idea. If I open that file in notepad it reads
""" the clarifai command line utility,
Basically it helps to setup the environmental variables for the
API Clients """
So this is exactly what I want to do set the 'environmental variables' CLARIFAI_APP_ID: and CLARIFAI_APP_SECRET: but i have no idea how to do this. I tried to run this in the windows command terminal and in the python terminal but get errors both times.
someone suggested below "You should probably run in the folder you installed it to". But I did not install this, pip installed this I I dont understand where it installed it to?
Where should do you think they are implying I run this from?
You do not need the $. You should probably run in the folder you installed it to, provided you didn't add to %PATH% yet. If you did, anywhere should be fine. Windows CMD or PowerShell is probably what they want.

Github desktop and git hooks

I am having an issue with implementing git hooks with the Github Desktop client for windows. When I created the hook, it runs a python script that checks the commit message. The weird part is, it runs on perfectly fine on Windows with command prompt, powershell, tortoisegit, webstorm IDE, git bash, also works on Linux terminal, EXCEPT for Github Windows client. reading the debug log, i get this error
GitHub.IO.ProcessException: /usr/bin/env: python: No such file or directory
My already attempted solutions:
adding 'python' as system variable
using ruby
removing '/usr/bin/env' (this will throw an error saying this file doesn't exists)
adding a .bashrc file solution i found online by putting the python path in my home directory
Does anyone have any idea how to fix this?
This error means that Git cannot find
To fix that, append C:\Python (or wherever you installed python) to your PATH environment variable in windows (control panel > System).
Once you set it up test the hook again.
Another option is to create a .bashrc file in your %USERPROFILE% directory and set the variable there:
export PATH=/c/Python:$PATH
Again - check to see that it fixed the problem.

Getting gcloud to work in Cygwin Windows

I am fairly new to programming. I have started app development on google app engine. I am trying to get the Google Cloud SDK to work with Cygwin 32 on Windows. I first ran the curl command to download the Google SDK files. Then I ran the install.py script and installed the SDK, however when calling gcloud in cygwin I receive this message:
Ammar Husain#Ammar-Computer:~
$ gcloud
/cygdrive/c/Users/Ammar Husain/google-cloud-sdk/bin/gcloud: line 102: C:\Python27: command not found
I have looked everywhere for a solution and have not been able to find one. I examined the gcloud file in the program files and it seems that there may be a problem with the Python Root Directory but I'm not sure. It may also be my Environment Variables.
Someone help?
I was having the same problem with Python not understanding the cygwin path. Instead of changing the gcloud script I created a C:/cygdrive folder. Then, I opened a windows command prompt and cded to the new folder. There, I ran mklink /D c C:\.
This created a link to the C: drive in such a way that Python understands /cygdrive/c/….
First: Cygwin 32? Do you have a 32bit machine? Otherwise the 64bit Version will be the better choice!
Please have a look here, if you DIDN'T install python via cygwin: Using python on windows
If you DID install it via cygwin: Set up python on windows
You might also have a look here: Set the pythonpath on cygwin
In all cases you have to add the python-directory to the PATH-Variable in Windows AND cygwin:
set PYTHONPATH=%PYTHONPATH%;C:\Path-to-python
echo "PATH=\$PATH:/cygdrive/c/Path-to-python" >> .bash_profile
After installing python 3.8 in my cygwin (with cygwin setup-x86_64.exe), I've used the versioned archive for Linux from
https://cloud.google.com/sdk/docs/downloads-versioned-archives
Then, I installed it in my cygwin home directory with this steps:
$ tar -xvf google-cloud-sdk-xxx.x.x-linux-x86_64.tar.gz
$ ./google-cloud-sdk/install.sh
$ source ~/.bashrc //
It worked for me

Can't open file 'django-admin.py': [Errno 2] No such file or directory

I'm using Python 2.7, Django 1.2.5 and on Windows 7.
I am not sure what I've done. I used to be able to create Django projects like
python django-admin.py startproject test
Now however I get this error.
Can't open file 'django-admin.py':
[Errno 2] No such file or directory
I can type the following which works.
python C:\Python27\Scripts\django-admin.py startproject test
How can I have it the way it used to be? Not having the type the full path to the django-admin.py file.
Things I've already tried:
I uninstalled Python and manually removed the values from the PATH variable in Windows. Reinstalled Python. Deleted Django and reinstalled it too.
I've added C:\Python27\Scripts to my PATH and PYTHONPATH variable under Environmental Variables in Windows.
Any suggestions?
My PATH variable contains
C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\ActiveState Komodo Edit 6\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\django-apps;F:\My_Projects;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Mercurial\bin;C:\Python27;C:\Python27\Scripts
PYTHONPATH has
C:\Python27;C:\Python27\Lib;C:\Python27\DLLs;C:\Python27\Lib\lib-tk;C:\Python27\Scripts;C:\django-apps;f:\my_projects
I had this same problem with slightly newer versions of Python 2.7.x and Django - and it is not the PATH. This is all I had to do to fix it in Windows XP:
Find a .py file (any, even a blank).
Right click on it and choose: "Open with>" and then select "Choose program...".
This pops up a list of all programs - select python, and check the box "Always use the selected program to open this kind of file" and then click OK.
Checking this box resets file associations and fixes this problem for the command line.
The cause of the problem: Telling Windows to open up .py files in a text editor as default.
If C:\Python27\Scripts is in your Path, just type in:
django-admin.py startproject proj
There should be a file association with .py and try to execute. If you prefix with python the next command is a file path.
I've never been able to do python django-admin.py -- I get the same error you describe.
Make sure python is associated with .py. You can check via file properties (opens with...) or typing assoc .py in cmd.
Here is what I did to get this working:
Installed Python 2.7 to C:\Python27 using the install package for Windows at python.org
I chose to install the latest release version of Django (1.3) (not the development trunk)
Installed Django following the instructions here: http://docs.djangoproject.com/en/dev/topics/install/
I'm only doing local development, so I skipped install of Apache and mod_wsgi (as directed in Django instructions)
I don't need a database for my app, so I skipped "Get your database running" section in Django instructions; and I skipped "Remove any old versions of Django" (didn't have any installed)
I skipped down the instructions to "Installing an official release"
I installed bsdtar as directed in order to untar the release files on my windows machine - ran no problem.
Being on Windows, I started a cmd shell with admin privileges and ran the command "setup.py install" - ran no problem
I followed the instruction to verify Django install: running import django and django.print get_version() - returned 1.3, success
Then it came time to run django-admin.py startproject myproject - I received similar errors to the above, and when trying to run django-admin.py from within the python interpreter, I received syntax errors pointing at the arguments. Strange.
Found this thread, and ran this, which worked: c:\Python27\Scripts\django-admin.py startproject myproject and it worked.
Still curious, I wanted to see if I could make it work from cmd prompt, without the paths, since it seemed that should work - and it didn't.
This is what I did beyond the install instructions that made it work for me on Windows:
Verified the file associations, using info from this post - all associations good.
Used Start|Computer|System Properties|Advanced System Properties|Environment Variables dialog to set the environment variables as follows:
Set New System Variable: PYTHONPATH = c:\Python27\Lib;c:\Python27\Scripts
Edit existing User variable: PATH added: C:\Python27;C:\Python27\Scripts to the end.
The result:
.py files now execute from cmd command line (no need to run python interpreter first)
e.g. the command django-admin.py startproject mynewproject ran just fine.
Please post any questions in the comments, maybe I can help.
Is it possible you associated your .py files with another program (like a text editor)? I had this problem, too, after associating .py files with gedit.
I'd have the problem if I did this:
python django-admin.py startproject myproject
Once I reassociated .py files to python this problem went away.
Gosh! It drove me crazy! Just do the following!
python C:\python27\scripts\django-admin.py startproject mysite
The problem seems to be with the file association. After adding the PATH variables, remove all "py" associations instead of linking them to your Python executable:
Remove the file type ".py " from the registry or by using a small
free tool for Windows Vista/Windows 7 called 'Unassoc' (google for Windows 7 unassoc).
In my case simply unassociating the file type was not enough. I had to remove the file type entirely using the unassoc tool.
Now you should be good to go.
I've solved it! It's the command line to open a file .py.
It has to be like so:
"C:\Python27\python.exe" "%1" %*
mine was:
"C:\Python27\python.exe" "%1" without the final %*
I've used FileTypesMan to edit because Windows 7 can't edit this property.
In my case it was solved by adding the path to django-admin.py.
The instruction in windows with a python 7 and django 1.11 is:
python c:\Python27\Lib\site-packages\django\bin\django-admin.py startproject mysite
First, set the path in PowerShell (in your $profile) like this:
$env:PATH = "C:\Python27\;C:\Python27\Scripts;c:\python27\lib\site-packages\django\bin\;"
Then, to get .py files to open in PowerShell rather than cmd, add this line:
$env:PATHEXT += ";.py"
Finally, to be able to just type "django-admin" and have it work, add this line:
function django-admin {python (gcm django-admin.py | resolve-path) $args}
That should do the trick.
After I installed an IDE, I had a similar (if not the same) problem. Sure enough, the .py "Open With" setting had been changed, and changing it back to the Python Launcher for Windows did the trick.
On Windows, I used
django-admin startproject test
and it seemed to have worked.
Since the path is too long, I moved the folders to a shorter path inside C: /. This way I call it faster, there is a problem with the route. I use Windows 10 with Django 3.0.5, so it turns out like this: python C:\Python38\Scripts\django-admin.py startproject test
The problem for me was the installation of Visual Studio.
I tried to install django-admin, which is usely automatically set up:
pip3 install django-admin
and it gave to me :
error: Microsoft Visual C++ 14.0 or greater is required.
So, I install Microsoft Visual Studio, and then it works.
Make sure that you cd is where you saved your Notepad++ Python file. If you saved it under your \Python27\ directory, then while in the terminal or PowerShell window, type cd C:\Python27 and press enter.
This will open that directory so when you type python filename.py it will find it and run it. Just remember to save all .py files to the same directory, so you have no further problems.
No Windows, usei:
python -m django startproject mysite

Categories