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

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.

Related

How do I activate a VSCode environment from ssh?

I am currently using VS Code on a server (through SSH). Everything works fine, and I installed Python packages and work with Python notebooks.
Now, I want to login to the server (not a problem) and run the Python code I created on VSCode, rather than executing it remotely.
My main issue is that I am not sure how to activate the Python environment (if there is one) that VSCode server's run so that the code can execute.
Is that possible?
I see I have a .vscode directory in my home directory, and there are package installation there.
After connecting vscode remotely, you can use it as a regular vscode, which is no different from running Python files locally:
install python
install pylance extension
choose correct interpreter
edit your code and run the python file.

RHEL Permission Denied whilst trying to Run Robot Framework

I am setting up Robot Framework on RHEL 8.4. I have python 3.6 installed on my machine. However, when I try to run robot from within python virtual environment it throws
-ksh: robot: cannot execute [Permission Denied]
I also ran whereis robot and gave all permissions to the robot file.
The error happens when I am trying to run robot as a user other than root from within the virtual environment however, it works fine when run within virtual environment as root.
However, I am not keen to continue normal development as root and would like this to work via my normal user.
It sounds quite strange but upgrading PIP resolved the issue.
While creating a new project. Select the parent directory to the folder where the RobotFramework file is stored. It will solve the problem.
C:\Robot Framework

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

"No Tests were found" in Pycharm Professional 2019.1 using Behave

Starting Python BDD, using Behave in pycharm 2019.1 pro. Just started learning Python and Pycharm IDE.
Used a basic example to run a feature file with one scenario in it.
When I run using Pycharm Terminal, the scenario runs fine. When I do the same while right clicking on the Scenario in the editor, I get the message at run time, "No tests were found".
I have searched on SO but responses are for unit tests not for BDD tests.
I went into the run/debug configuration and have tried setup working directory to my feature folder or the project folder, but still the same issue.
I previously had python 3.7 but now using python 3.6 (both installed) and the interpreter is set to behave
I got it working but uninstalling pycharm, python 3.6 and python 3.7 folders completely (includuing hidden folders from private # root) from my machine, fresh install pycharm with python 3.6 and then behave. Tests work now.
No idea exactly why it happened except that it could be some conflicting config due to different python versions.

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

Categories