in google app engine
get error in runing the appicaition
in logs of googleappengine
2012-04-21 13:24:04 Running command: "['C:\Python32\pythonw.exe', 'C:\Program Files\Google\google_appengine\dev_appserver.py', '--admin_console_server=', '--port=8080', 'C:\udacity\googleapps\hello-udacity']"
Traceback (most recent call last):
File "C:\Program Files\Google\google_appengine\dev_appserver.py", line 125, in
run_file(file, globals())
File "C:\Program Files\Google\google_appengine\dev_appserver.py", line 121, in run_file
execfile(script_path, globals_)
NameError: global name 'execfile' is not defined
2012-04-21 13:24:07 (Process exited with code 1)
You appear to be running Python 3.2 (your Python executable is on this path 'C:\Python32\pythonw.exe').
Google AppEngine requires Python 2.5 or 2.7 at this stage, see this article. You need to download Python 2.7, install it in a parallel directory, and make it the default executable.
You may find it helpful to read this answer on running more than one version of Python
Also, I had the same problem. This is because I have installed both Python 2.7 and Python 3.x (the latest version of the framework Django uses the latter). I installed Python 3.x later so this is the version that is used by default in my system. To use Python 2.7 you could do the following:
C:\Python27\python.exe dev_appserver.py path-to-your-app
Notice that here
C:\Python27\python.exe
is the path to the python 2.7 executable (in my case, but this could vary).
I did that and it worked.
More info and reading here.
Related
When I am using repo init to initialize some repo from a source, I keep getting:
Traceback (most recent call last):
File "/home/workspace/.repo/repo/main.py", line 56, in <module>
from subcmds.version import Version
File "/home/workspace/.repo/repo/subcmds/__init__.py", line 38, in <module>
['%s' % name])
File "/home/workspace/.repo/repo/subcmds/upload.py", line 27, in <module>
from hooks import RepoHook
File "/home/workspace/.repo/repo/hooks.py", line 472
file=sys.stderr)
^
SyntaxError: invalid syntax
The following are the python versions I have:
python -V -> 2.7
python3 -V -> 3.6
According to this link, python 3.6 is required starting with repo-1.14 but I'm not certain if that's what my repo version is - didn't have any luck finding a way around determining the version.
Looks like you are running an old repo launcher script version that is incompatible with the latest repo version. To fix this, download the latest repo launcher python script from Google and replace your outdated one.
The launcher script is the executable python script called "repo" and is located in your PATH, usually ~/bin (according to Google's instructions) or ~/.local/bin/. To find out where yours is located, type which repo in the terminal and it will print the script's location.
Let's say your repo script is in ~/bin. To download the script (and make it executable), you can do:
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
Also, you do not need to remove Python 2.7 for repo to work. I use Ubuntu 18.04 and have both Python 2.7 and 3.6 installed as well, and repo runs fine.
I have some Python (jython actually) scripts that run with Sikulix.
I was previously using version 1.1.1 and was using the command line (after doinmg the setup):
java -Dsikuli.Debug=-2 -cp sikulix.jar org.python.util.jython main.py
With version 1.1.4, there is no more setup, and jython has been removed from sikulix.jar and sikulixapi.jar. Jython is in another jar file (jython-standalone-2.7.1.jar).
I tried to run with following command line
java -Dsikuli.Debug=-2 -cp "sikulix.jar;jython-standalone-2.7.1.jar" org.python.util.jython main.py
But I get the following error
Traceback (most recent call last):
File "test.py", line 3, in <module>
from sikuli.Sikuli import *
ImportError: No module named sikuli
The documentation is not fully updated on how to do it. They mention installation of jython, jip and other stuff but nothing managed to work.
Any idea on how to do it?
Thanks
==PS==:
After doing the following it almost worked:
Installing jython
Setting CLASSPATH to absolute path of sikulixapi.jar
Running jython main.py
I got the following error:
[error] RunTimeINIT: *** terminating: Java arch not 64 Bit or not detected (java 8-32 version 1.8 vm 25.121-b13 class 52.0 arch null)
I have installed Jython with a 32-bits Java and it seems 64-bits Java is required.
I will probably try again with 64-bits Java JDK.
Add the following line at the beginning of your script
import org.sikuli.script.SikulixForJython
This will help to look for sikuli module in Java classes.
You can then run with the command line mentionned previously:
java -cp "sikulixapi.jar;jython-standalone-2.7.1.jar" org.python.util.jython main.py
Example of Python script (main.py):
import org.sikuli.script.SikulixForJython
from sikuli.Sikuli import *
notepad = App('notepad.exe')
notepad.open()
sleep(1)
type("It is working!")
notepad.close()
I am trying to build a Python Script into a stand alone application. I am using GUI2Exe. My script uses selenium package. I have it installed.
Project compiles fine and runs on python command line directly but fails to build a stand alone because it is referring to folder:
ERROR: test_file_data_extract (__main__.FileDataExtract)
----------------------------------------------------------------------
Traceback (most recent call last):
File "File_data_extract.py", line 18, in setUp
File "selenium\webdriver\firefox\firefox_profile.pyc", line 63, in __init__
IOError: [Errno 2] No such file or directory: 'C:\\users\\username\\PycharmProjects\\Python_27_32bit\\file_data_extract\\dist\\File_data_extract.exe\\selenium\\webdriver\\firefox\\webdriver_prefs.json'
It is looking for selenium package is located at :
C:\Users\username\Anaconda2_Py27_32bit\Lib\site-packages\selenium-2.48.0-py2.7.egg\selenium\webdriver\firefox
where C:\Users\username\Anaconda2_Py27_32bit is where I installed Anaconda Python 2.7, 32 bit version. By default it is looking for in \dist\filename.exe folder.
I was able to build it using bbfreeze. It works great.
First I had to install bbfreezee via pip (one time only):
pip install bbfreeze
Create a build_package.py file as:
from bbfreeze import Freezer
f = Freezer("project_name", includes=("selenium","SendKeys",)) #list problem packages here to manually include
f.addScript("project_name_script.py")
f() # starts the freezing process
Build project:
python build_package.py bdist_bbfreezee
in folder project_name where project_name_script.py sits you find project_name_script.exe with all the include packages including selenium and sendkeys. When you distribute the package you need to distribute entire project_name because it contains all dependent library dlls (python .pyd).
More details refer official bbfreezee here:
https://pypi.python.org/pypi/bbfreeze/#downloads
trying to run a flask dev server on localhost:5000 using a virtualenv on Windows 7
In my command line in the project directory, i activated the virtualenv with the command "env\scripts\activate". It seemed to work, as my next line was preceded with an (env) tag. When I attempted to run the app file (bank_app), however, I got an import error.
Here's the console log
C:\Users\TJ\Documents\Python Projects\TestingPython> env\scripts\activate
(env) C:\Users\TJ\Documents\Python Projects\TestingPython> bank_app
Traceback (most recent call last):
File "C:\Users\TJ\Documents\Python Projects\TestingPython\bank_app.py", line 1, in <module>
from flask import Flask
ImportError: No module named flask
and here's a gist of the bank_app file (just in case it's relevant)
I'm used to running the code directly from PyCharm, which handles the virtualenv for me. it works fine running directly from PyCharm
This is probably related to how Windows maps extensions to executables.
You started the script with bank_app, which is really not the name of your script (your script has a .py extension I assume?). Windows must be doing a search in your directory, and then starting the script with the interpreter that is registered for the .py extension of the script, which is the globally installed interpreter, not the interpreter that is currently in the PATH.
I'm pretty sure if you run the command as python bank_app.py everything will work just fine.
After I broke my Ubuntu precise with a Cython compilation I like to keep the system Python clean. I like to have 2.7.x & 3.4.x besides each other and used Pyenv to have a global default interpreter independent from the system python. Now I also want to define local interpreters on a per project basis, usually done with pyenv local. Unfortunately my favorite IDE PyCharm does only support pyenv global, the local .python-version files are obviously not recognized by PyCharm.
So I tried to use the pyenv global interpreter in PyCharm with ~/.pyenv/bin/python-local-exec which works but unfortunately is already deprecated. When I then tried to create a virtualenv from the pyenv Python 3 global interpreter, it throwed the follwing error:
The following command was executed:
virtualenv.py /home/barrios/code/so/venv
The error output of the command:
pyenv: `python-local-exec' is deprecated and will be removed in the next release.
To upgrade: https://github.com/yyuu/pyenv/wiki/python-local-exec
Failed to import the site module
Traceback (most recent call last):
File "/home/barrios/code/so/venv/lib/python3.4/site.py", line 67, in <module>
import os
File "/home/barrios/code/so/venv/lib/python3.4/os.py", line 634, in <module>
from _collections_abc import MutableMapping
ImportError: No module named '_collections_abc'
Using base prefix '/home/barrios/.pyenv/versions/3.4.0b3'
New python executable in /home/barrios/code/so/venv/bin/python
ERROR: The executable /home/barrios/code/so/venv/bin/python is not functioning
ERROR: It thinks sys.prefix is '/home/barrios/.pyenv/bin' (should be '/home/barrios/code/so/venv')
ERROR: virtualenv is not compatible with this system or executable
As mentioned before, I don't want to install Python 3 into my Ubuntu system folders. Any ideas how to achieve that?
TNX a lot!
I'd suggest to use https://github.com/yyuu/pyenv-virtualenv to create virtualenv for a desired interpreter and then add it as a Python interpreter in PyCharm.