ImportError cannot import name 'dump_options_header' - python-3.5

whene i run my application odoo in eclipse i got this error
`>from werkzeug.http import dump_options_header, dump_header, generate_etag, \
ImportError: cannot import name 'dump_options_header'
from werkzeug.http import dump_options_header, dump_header, generate_etag, \
quote_header_value, parse_set_header, unquote_etag, quote_etag, \
parse_options_header, http_date, is_byte_range_valid
from werkzeug import exceptions`

what is your version of Werkzeug ?
Find the version with one of this commands
pip list
if you have install flask
flask.__version__
pip freeze | grep Flask
flask --version
If it is 1.0.0 try your after Werkzeug downgrade
pip install Werkzeug==0.16.1

Related

ImportError: cannot import name 'load_learner' from 'fastai'

I'm new to fastai.
fastai 2.7.5
fastcore 1.4.5
nbdev 1.2.10
torch 1.12.0
torchvision 0.13.0
from fastai import load_learner
learn = load_learner('export_2.pkl', cpu=False)
>>> ImportError: cannot import name 'load_learner' from 'fastai' (/home/daniel/miniconda3/envs/pdl1lung/lib/python3.9/site-packages/fastai/__init__.py)
from fastai.vision.all import *
conda create -n venv python==3.6.13
pip install -r requirements.txt
requirements.txt:
fastai==2.5.3
fastcore==1.3.27
python==3.6.13

Flask Version Incompatibility issue

I am a newbie to flask and I am developing a small API for my team using Flask.
Earlier when I was using python 3.8 and pip older version ( I am not sure what version that was), my app.py was running fine. But whenever I did a pip install <SOME_PACKAGE_NAME>, I used to get a message stating to upgrade my pip, and so I upgraded it to pip 21.1.1. After upgrading the pip, I also updated python 3.8 to python 3.9 and created a new python virtual environment, and tried installing the below three libraries there that are required for my application:-
Flask
Flask-RESTful
Flask-JWT
But I saw that my flask and other packages have the latest versions, so I tried running my app in the new virtual environment, but it keeps failing. I am adding below the steps along with the failure message and a few other info.
(base) Apples-MacBook-Pro:pythonEnvs testuser$ virtualenv -p python3.9 venvTest
(base) Apples-MacBook-Pro:pythonEnvs testuser$ cd ../Documents/Personal/FlaskProject/src/Flask-Api/
(base) Apples-MacBook-Pro:Flask-Api testuser$ source ~/pythonEnvs/venvTest/bin/activate
(venvTest) (base) Apples-MacBook-Pro:Flask-Api testuser$ pip --version
pip 21.1.1 from /Users/testuser/pythonEnvs/venvTest/lib/python3.9/site-packages/pip (python 3.9)
(venvTest) (base) Apples-MacBook-Pro:Flask-Api testuser$ python --version
Python 3.9.5
(venvTest) (base) Apples-MacBook-Pro:Flask-Api testuser$ pip install flask
(venvTest) (base) Apples-MacBook-Pro:Flask-Api testuser$ pip install Flask-RESTful
(venvTest) (base) Apples-MacBook-Pro:Flask-Api testuser$ pip install Flask-JWT
(venvTest) (base) Apples-MacBook-Pro:Flask-Api testuser$ python3.9 app.py
Traceback (most recent call last):
File "/Users/testuser/Documents/githubProjects/FlaskProject/src/Flask-Api/app.py", line 2, in <module>
from flask_restful import Api
File "/Users/testuser/pythonEnvs/venvTest/lib/python3.9/site-packages/flask_restful/__init__.py", line 14, in <module>
from flask.helpers import _endpoint_from_view_func
ImportError: cannot import name '_endpoint_from_view_func' from 'flask.helpers' (/Users/testuser/pythonEnvs/venvTest/lib/python3.9/site-packages/flask/helpers.py)
I am fortunate enough to have the pip freeze from the older pip version, so I pasted that into requirements.txt and do an explicit pip install on it, and am running the application for now on it. But what exactly is the issue with the new Flask and other dependencies version.
Below are the results of pip freeze from older pip and after upgrading and installing libraries in the new virtual environment: -
# Pip Freeze from an older version
aniso8601==9.0.1
click==7.1.2
Flask==1.1.2
Flask-JWT==0.3.2
Flask-RESTful==0.3.8
itsdangerous==1.1.0
Jinja2==2.11.3
MarkupSafe==1.1.1
PyJWT==1.4.2
pytz==2021.1
six==1.16.0
# Pip Freeze from the new version ( pip 21.1.1 )
aniso8601==9.0.1
click==8.0.0
Flask==2.0.0
Flask-JWT==0.3.2
Flask-RESTful==0.3.8
itsdangerous==2.0.0
Jinja2==3.0.0
MarkupSafe==2.0.0
PyJWT==1.4.2
pytz==2021.1
six==1.16.0
Werkzeug==2.0.0
Below is my app.py which I am trying to run:-
from flask import Flask
from flask_restful import Api
from flask_jwt import JWT
from security import authenticate, identity
from resources.user import UserRegister
from resources.item import Item, ItemList
# Resources are something our API is concerned with ( let it be students, items etc)
app = Flask(__name__)
app.secret_key = 'flask_application'
api = Api(app)
jwt = JWT(app, authenticate, identity) # JWT creates a new endpoint /auth
api.add_resource(Item, '/item/<string:name>')
api.add_resource(ItemList, '/items')
api.add_resource(UserRegister, '/register')
if __name__ == "__main__":
app.run(port=5000, debug = True) # To debug use (debug = True)
Please do let me know in the comments if anything is required.
( Authenticate and identity are functions used to authenticate users from our DB
UserRegister, Item, and ItemList are classes with some pre-defined attribution required for the respective endpoints)
Any insights into this will be of great help.
Thanks
Flask-Restful was no longer compatible with the recently released Flask 2.0.
A fix was applied some hours ago:
https://github.com/flask-restful/flask-restful/commit/fc9b34c39472284a57c50d94fec5b51fe8d71e14
There is no new release on PyPI yet.
You could either install Flask-Restful via GitHub or wait some time for a new release and meanwhile use your older pinned versions.

No module named 'pandas_datareader' in Jupyter (Anaconda) after I run pip3 install pandas_datareader

I am trying to learn pandas and want to load some stocks data. I was following a course which advised me to load pandas.io.data, but this did not work as io.data was depreciated. So I decided to use pandas-datareader instead. But I am struggling to instal it on mac in Anaconda (Jupiter notebook).
First time I run import pandas_datareader as pdweb I got ModuleNotFoundError: No module named 'pandas_datareader'. Not surprising as I never used this before so I run pip3 install pandas_datareader in Terminal which successfully installed itself. However, Jupiter notebook is still giving me the same error. At this point, I tried running in Terminal conda install -c https://conda.anaconda.org/anaconda pandas-datareader but it did not work as -bash: conda: command not found.
Please help. I am looking for a detailed explanation as I am not too techie.
What I run in Jupiter
import numpy as np
from pandas import Series, DataFrame
import pandas as pd
import pandas_datareader as pdweb
import datetime
Result
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-6-da568f513c93> in <module>
2 from pandas import Series, DataFrame
3 import pandas as pd
----> 4 import pandas_datareader as pdweb
5 import datetime
ModuleNotFoundError: No module named 'pandas_datareader'
Just run
conda install -c anaconda pandas-datareader
as per instructions here.
In my experience, if you're using conda, you should never install with pip unless you're sure conda doesn't have it. Try searching anaconda.org to see which -c source to use.
The problem was with conda command not being set up during the installation of Anaconda. I solved this by removing Anaconda with App Cleaner & Uninstaller Pro (free soft) and reinstalling later version.
After reinstallation of Anaconda command below worked like a charm.
conda install -c anaconda pandas-datareader
If you using Anaconda and still have issues installing panads-datareader using the conda command 'conda install -c anaconda pandas-datareader'. or the installation is successful but the import pandas_datareader.data as web still gives an error.
Locate where your 'site-packages % ' directory and cd to the site-packages % dir and then run the installation command 'conda install -c anaconda pandas-datareader '. It will work.
For the install, try using
pip
instead of
pip3

I can't import Peewee in Python3

In Python 2 I can import peewee but when I run Python3 I can't import peewee. It says module not found.
What should I do?
Thanks.
Install pip3 and then run pip3 install peewee this show a progress bar of the installation

Cannot import python package installed to virtualenv

I installed the python package Pillow to my virtualenv, but cannot import it. pip list | grep Pillow shows that it has been installed, and the virtualenv has been activated, but import Pillow still returns:
ImportError: No module named 'Pillow'
The virtualenv was created with
virtualenv -p python3.5 MainEnv
Pillow was installed with
pip install Pillow
Why can I not import the installed package?
I believe you pip install as Pillow, but import as PIL:
http://www.pythonforbeginners.com/gui/how-to-use-pillow

Resources