dev_appserver.py does nothing in CMD on windows - python

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

Related

Unable to Debug Dev Appserver using pycharm, but able to run fine

Attempting to run a python 2.7 app engine app locally using PyCharm (which uses dev_appserver) my machine is python 3.7 but I have a python 2.7 virtual env setup as the project interpreter, which works fine when running the project.
However when attempting to debug the same run config (which runs fine) I am getting the following error
ERROR: (dev_appserver) python2: command not found
I can run the python2 command in my terminal both inside and outside the virtual environment so I am not sure what is wrong here.
I am currently running Pop!_OS 20.04 LTS if that helps.
I have the same issue on mac catalina with Pycharm 2020.1.2.
I was able to start the debugger by using a "Python configuration", rather than a "App Engine Server" configuration. Steps below:
Click "Edit Configurations", and add a new "Python Configuration"
In the Script Path, enter the full path to dev_appserver.py
In Parameters, enter '--max_module_instances="default:1" .' (according to https://cloud.google.com/appengine/docs/standard/python/tools/using-local-server#debugging_with_pdb)
In Working Directory, enter the path to your project
This isn't perfect, but at least you can run the debugger within pycharm.
I look forward to a better answer some day that works with the "App Engine Server" configuration.
I had the same issue after starting new AppEngine projects on python 3. Initially, I thought the problem was with a new version of Google Cloud SDK. I spent a lot of time linking/unlinking python versions and playing around the environment variables.
But eventually, update of PyCharm to 2021.1.2 fixed the issue.

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.

appcfg.py command not found

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

python Bad Interpreter error

I am trying to install Sublime Text 2 on my linux machine and I cannot figure out how to run the python script to install it. I am fairly new to linux and never programmed in python before. I am trying to run the python script PackageSetup.py using ./PackageSetup.py but i get the error:
bash: ./PackageSetup.py: python: bad interpreter: No such file or directory
not sure what I have to do. I have python on my machine. I can tell cause running 'python' puts me in the console.
For all I know this kind of issue can occur if you have a misspelling or mistake in the shebang. I see two ways to solve this issue: you can try to invoke PackageSetup.py via python, like python PackageSetup.py or you can open PackageSetup.py and try to find an issue in the shebang, maybe it needs to be a full path to python interpreter like /usr/bin/python not just python.
BTW, why don't you try to install it via some kind of package manager - there is a repo for debian-based distros, and I'm pretty sure that there have to be repositories for other distributives.

Nothing happens when I do: python manage.py command

I'm new to django and currently going through the main tutorial. Even though it was working earlier, when I do python manage.py runserver OR python manage.py -h OR with any other command, the shell doesn't output anything. Wondering what I'm doing wrong.
The problem is that the first line in manage.py breaks the file on windows.
The first line should look like this:
#!/usr/bin/env python
Removing it will fix the issue.
First, check if python is fully installed by typing "python" in a shell.
Then you should try python manage.py runserver inside your django project. If you don't have any django project, try creating one by typing django-admin.py startproject mysite. If nothing is displayed in your shell, you must have installed Django the wrong way.
Please refer to Django Documentation at https://docs.djangoproject.com/en/1.4/intro/install/
If you had your server running till one point and a certain action/change broke it, try going back to the previous state.
In my case there was an email trigger which would put the system in an invalid state if email doesn't go through. Doing git stash followed by selectively popping the stash and trying the runserver helps narrow down the problem to a particular file in your project.
Please try this.
Uninstall Python.
Go inside C drive and search Django. You will get many Django related files.
Delete every Django file. 😁 don't delete your Django files.
Install Python.
It's worked for me.
if you created a virtual environment then activate it. you can try this command(in virtual environment directory) if you're using windows os:
.\Scripts\activate
On Ubuntu works for my by running manage.py as script:
./manage.py runserver
Just stuck with the same problem. Found a solution that works, but tedious.
You need to know the location of the python.exe file in your computer. It is usually
C:/Users/USERNAME/AppData/Local/Programs/Python//python.exe
Modify as required and run the following in CMD,
C:/Users/USER1/AppData/Local/Programs/Python/Python38-32/python.exe
F:/mysite/manage.py runserver
Hope this works :)
if you are using Redis Server on Windows, check it out if Redis Server is running, I had same problem and realized my Redis Server was not running, I ran it and now my manage.py commands work fine.
The same happened with me also, but this issue is a minor one as it happens if you have multiple versions of Python on your system, you can select a specific Python version by running python3 or whichever version you want.
SO you should start from the beginning, uninstall Django first then,
create a virtual environment, decide upon a directory where you want to place it, and run the venv module as a script with the directory path:
for e.g:
python3 -m venv tutorial-env
//This will create the tutorial-env directory if it doesn’t exist, and also create directories inside it
Once you’ve created a virtual environment, you may activate it.
On Windows, run:
tutorial-env\Scripts\activate.bat
On Unix or MacOS, run:
source tutorial-env/bin/activate
Now,
In the command prompt, ensure your virtual environment is active, and execute the following command:
...> py -m pip install Django
NOTE:
If django-admin only displays the help text no matter what arguments it is given, there is probably a problem with the file association in Windows. Check if there is more than one environment variable set for running Python scripts in PATH. This usually occurs when there is more than one Python version installed.
Another solution, if you can, is to upgrade Django
pip install django --upgrade
Oftentimes one will get other unrelated issues to solve that are linked with the upgrade but once all is fixed the server should run just fine.
If you can't upgrade Django, this problem also happens when the code was built using Python 2.x and you're locally using Python 3.x.
The quicker fix in that case is to uninstall Python 3.x from your machine and make sure Python 2.x was added to the path. I've seen some developers setting up alias in PowerShell to have more than one version in the environment too.
I think the problem is in manage.py file (50%), check it with an another file that is correct.

Categories