I've just migrated from the Python 2.5 to the 2.7 runtime, and most of server I've written runs fine. However I'm occassionaly seeing this odd stack trace (I've hacked it down for brevity):
ERROR 2013-04-23 10:40:15,598 wsgi.py:235]
Traceback (most recent call last):
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/jinja2-2.6/jinja2/environment.py", line 894, in render
return self.environment.handle_exception(exc_info, True)
File "templates/querystart.html", line 30, in top-level template code
{% for session in sessions %}
ImportError: No module named _sqlite3
I've not imported sqlite3 myself, and I don't rely on it. The code that's calling it is pretty simple (perhaps bordering on the dumb side of things):
class UserIdQuery(BaseHandler):
def get(self):
sessionQuery=Session.all().order("userid")
template_values = {
'sessions': sessionQuery,
}
self.render_template('querystart.html',**template_values)
The above simply extends the below (taken from a very helpful migration tutorial)
class BaseHandler(webapp2.RequestHandler):
#webapp2.cached_property
def jinja2(self):
return jinja2.get_jinja2(app=self.app)
def render_template(self, filename, **template_args):
self.response.write(self.jinja2.render_template(filename, **template_args))
Anyone know what might be triggering the import error? Thanks,
Appengine uses sqlite for the datastore, my bet is your python2.7 installed on OSX is missing the sqlite binary library. Do a quick test, start a python interpreter (outside of appengine) and try to import sqlite3
$ python
Python 2.7.3 (default, Sep 26 2012, 21:53:58)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>>
If that fails you know you have an incomplete 2.7 runtime installed.
I was having the same problem and fixed it.
I was running python 2.7.3 that I installed from Ninite.com.
Uninstalled python, downloaded and installed 2.7.5 installer directly from python.org and problem has gone away.
Related
So I am pretty new to the ML world and currently following fastai's deep learning course. I tried to import gradio on my local machine's Jupyter. (using mamba). Whenever I try to import the module as
import gradio as gr
it gives me this error:
Traceback (most recent call last):
File "/home/eren/.local/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 3343, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-5-43eca54f7d45>", line 1, in <module>
import gradio as gr
File "/home/eren/.local/lib/python3.6/site-packages/gradio/__init__.py", line 3, in <module>
import gradio.components as components
File "/home/eren/.local/lib/python3.6/site-packages/gradio/components.py", line 5
from __future__ import annotations
^
SyntaxError: future feature annotations is not defined
Any idea about what I need to do is appreciated.
I tried installing gradio in the environment, the error:
Looking for: ['gradio']
conda-forge/linux-64 No change
conda-forge/noarch 10.9MB # 2.1MB/s 5.3s
Pinned packages:
- python 3.10.*
Could not solve for environment specs
Encountered problems while solving:
- nothing provides requested gradio
The environment can't be solved, aborting the operation
From the traceback it looks like you're using python version 3.6.
At the moment, gradio supports python versions 3.7 and above (as seen here)
Prerequisite: Gradio requires Python 3.7 or higher, that's all!
As mentioned in this answer, the future feature annotations is only implemented in python 3.7 onwards.
I am trying to deploy an Airfow DAG to MWAA.
My requirements.txt:
apache-airflow[amazon] == 3.2.0
I import EcsOperator like this:
from airflow.contrib.operators.ecs_operator import EcsOperator
However, I get this error:
Broken DAG: [/usr/local/airflow/dags/mydag.py] Traceback (most recent call last):
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/usr/local/airflow/dags/mydag.py", line 4, in <module>
from airflow.contrib.operators.ecs_operator import EcsOperator
ImportError: cannot import name 'EcsOperator' from 'airflow.contrib.operators.ecs_operator' (/usr/local/lib/python3.7/site-packages/airflow/contrib/operators/ecs_operator.py)
What am I doing wrong here?
What am I doing wrong here?
You might be referencing a different version (1.10.12?) of the Airflow documentation.
airflow.contrib.operators.ecs_operator (1.10.12)
The documentation for 3.2.0 is here. You can import the EcsOperator like this:
from airflow.providers.amazon.aws.operators.ecs import EcsOperator
airflow.providers.amazon.aws.operators.ecs (3.2.0)
The correct requirements.txt:
(empty)
And the correct import:
from airflow.providers.amazon.aws.operators.ecs import ECSOperator
Note the casing!
There are several issues here so I'll compile a detailed answer since privious answers didn't cover all of them.
First, the updated import path (provider release 3.2.0) is:
from airflow.providers.amazon.aws.operators.ecs import EcsOperator
The reason this doesn't work for you is because you install the provider with extras as:
apache-airflow[amazon]
as explained in the provider extra docs when installing provider in that manner you get the provider version which was released at the time of the Airflow version that you are using. Thus you are not guaranteed to get the updated provider version. So in case you are using Airflow 2.2.4 (latest at the time of writing this answer) you will get Amazon provider version 3.0.0 which is not the most recent one.
To get updated provider you should install it as:
pip install apache-airflow-providers-amazon
if you like to pick a specific version then:
pip install apache-airflow-providers-amazon==3.2.0
Please note that you should always install from constraint files provided by Airflow. Example:
pip install "apache-airflow-providers-amazon" --constraint "https://raw.githubusercontent.com/apache/airflow/constraints-main/constraints-3.7.txt"
Note that the provider is referring to constraints-main which constantly updated and not to constraints-2.2.4 or any other specific Airflow version.
You can read more about it in the doc about Installation and upgrading of Airflow providers separately.
I am trying to call rpy2.robjects which is giving below mentioned error. I am using rpy2 package(3.4.5) in python 3.5.10. R installed version is 3.4.1.
import rpy2.robjects as ro
Traceback (most recent call last):
File "test.py", line 1, in <module>
import rpy2.robjects
File "/usr/local/lib64/python3.5/site-packages/rpy2/robjects/__init__.py", line 16, in <module>
import rpy2.rinterface as rinterface
File "/usr/local/lib64/python3.5/site-packages/rpy2/rinterface.py", line 13, in <module>
import rpy2.rinterface_lib._rinterface_capi as _rinterface
File "/usr/local/lib64/python3.5/site-packages/rpy2/rinterface_lib/_rinterface_capi.py", line 97
_cdata: FFI.CData
^
Syntax error : invalid syntax
[Rp2_error][1]
I am running this command from AWS EC2 instance where it is required to call an R function from python.
The same command is working in windows after setting R_HOME.
In EC2 instance, tried 2 paths for R_HOME,
os.environ['R_HOME'] = '/usr/lib64/R/'
or '/usr/bin/R'
The issue persists in both cases.
R.home is '/usr/lib64/R/' (R prompt)
rpy2 3.4.x requires Python >=3.6 as described in the documentation (installation section). The error you see is because Python 3.5 did not support typing.
You need to upgrade your Python version. Python 3.5 support ended 1 year ago and its not safe to use it - you may be exposed to unpatched security bugs. Given that support for 3.6 ends in two months I would recommend upgrading straight to 3.7 or 3.8.
I have created virtualenv for python3 using:
virtualenv -p $(which python3) ENV
Then activate the source
source /Users/myusername/ENV/bin/activate
Install the apache-airflow:
pip install apache-airflow
then which airflow yields /Users/myusername/ENV/bin/airflow
But when I try to initdb using:
airflow initdb
I get below error:
{db.py:350} INFO - Creating tables
INFO [alembic.runtime.migration] Context impl SQLiteImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
WARNI [airflow.utils.log.logging_mixin.LoggingMixin] cryptography not found - values will not be stored encrypted.
ERROR [airflow.models.DagBag] Failed to import: /Library/Python/2.7/site-packages/airflow/example_dags/example_http_operator.py
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/airflow/models/__init__.py", line 413, in process_file
m = imp.load_source(mod_name, filepath)
File "/Library/Python/2.7/site-packages/airflow/example_dags/example_http_operator.py", line 27, in <module>
from airflow.operators.http_operator import SimpleHttpOperator
File "/Library/Python/2.7/site-packages/airflow/operators/http_operator.py", line 21, in <module>
from airflow.hooks.http_hook import HttpHook
File "/Library/Python/2.7/site-packages/airflow/hooks/http_hook.py", line 23, in <module>
import tenacity
File "/Library/Python/2.7/site-packages/tenacity/__init__.py", line 375, in <module>
from tenacity.tornadoweb import TornadoRetrying
File "/Library/Python/2.7/site-packages/tenacity/tornadoweb.py", line 24, in <module>
from tornado import gen
File "/Library/Python/2.7/site-packages/tornado-6.0.3-py2.7-macosx-10.14-intel.egg/tornado/gen.py", line 126
def _value_from_stopiteration(e: Union[StopIteration, "Return"]) -> Any:
^
SyntaxError: invalid syntax
Done.
(ENV) ---------------------------------------------------------
Seems like example scripts use python 2.7 and it can't recognize the function definition syntax.
Does apache-airflow package need to be fixed by the next release or I can do something to fix this?
I tried fixing this:
Use python2.7 instead of python3
then install airflow on default python 2.7 enabled on mac but this throws other errors like package "six" is not compatible.
You need to turn off the example DAGs to be loaded in config file to solve this problem.
Anyway, it seems weird that airflow uses 2.7 Python when you told that it is installed into Python 3 virtual environment.
I am trying to launch the hello world sample,I use TideSDK 1.3.1-beta with Tide SDK Developer,I have install all the needed components such as imagick,wix and python 2.7 ,But I am getting this error during launch :
Preparing to package and launch desktop app. One moment...
C:\Python27\\lib\site.py:158: Warning: 'with' will become a reserved keyword in Python 2.6
'import site' failed; use -v for traceback
C:\Python27\\lib\linecache.py:127: Warning: 'with' will become a reserved keyword in Python 2.6
C:\Python27\\lib\linecache.py:127: Warning: 'with' will become a reserved keyword in Python 2.6
Traceback (most recent call last):
File "C:\ProgramData\TideSDK\sdk\win32\1.3.1-beta\tidebuilder.py", line 36, in
import env
File "C:\ProgramData\TideSDK\sdk\win32\1.3.1-beta\env.py", line 32, in
import app
File "C:\ProgramData\TideSDK\sdk\win32\1.3.1-beta\app.py", line 34, in
import os, os.path as p
File "C:\Python27\\lib\os.py", line 63, in
import ntpath as path
File "C:\Python27\\lib\ntpath.py", line 12, in
import warnings
File "C:\Python27\\lib\warnings.py", line 6, in
import linecache
File "C:\Python27\\lib\linecache.py", line 127
with open(fullname, 'rU') as fp:
^
SyntaxError: invalid syntax
Done launching!
I have fixed the problem , Since TideSDK comes with its own Python runtime,I created an environmental variable pointing to that python runtime so this was how I did it . [code] variable home : PYTHONHOME variable vaulue : C:\ProgramData\TideSDK\modules\win32\python\1.3.1-beta
It almost seems like it's using a different Python version, although the folder clearly says 2.7. Did you have another version of Python installed before? If so, did you change the environment variable to point to 2.7 after installing 2.7? Maybe confirm with python --version.