How to change MarkUpSafe version in virtual environment? - python

I am trying to make an application using python and gRPC as shown in this article - link
I am able to run the app successfully on my terminal but to run with a frontend I need to run it as a flask app, codebase. And I am doing all this in a virtual environment.
when I run my flask command FLASK_APP=marketplace.py flask run
This is the error I get
ImportError: cannot import name 'soft_unicode' from 'markupsafe' (/Users/alex/Desktop/coding/virt/lib/python3.8/site-packages/markupsafe/__init__.py)
On researching about this error I found this link - it basically tells us that currently I am using a higher version of MarkUpSafe library than required.
So I did pip freeze --local inside the virtualenv and got MarkUpSafe version to be MarkupSafe==2.1.0
I think if I change the version of this library from 2.1.0 to 2.0.1 then the flask app might run.
How can I change this library's version from the terminal?
PS: If you think changing the version of the library won't help in running the flask app, please let me know what else can I try in this.

If downgrading will solve the issue for you try the following code inside your virtual environment.
pip install MarkupSafe==2.0.1

Related

ERROR: Can not execute `setup.py` since setuptools is not available in the build environment (error getting installing during Socketio module)

I'm getting error during installing of **Socketio **module for Python which is use for Websocket.
using this command: pip install socketio
But i'm getting this error, I don't know how can i solve this.
My current Python version is - 3.10.8
And Setuptools version is - 65.5.1
And i'm using latest version of pip
I tried some websites where people ask this question and i tried them nothing help.
Please don't tell me use virtual environment because i don't want to use it.
I try this code for using Websocket,
So for that i want to install socketio module.

is there a way to solve the problem No module named 'werkzeug.posixemulation' on odoo14

I have configured pycharm to develop odoo modules and launch the odoo server. it worked without problem and one day I launched a python flask project under the same interpreter and since then I can't launch my odoo server, when I try I get this error "No module named 'werkzeug.posixemulation'". I'm a beginner and how can I solve my problem. thank you. I'll throw in an image if needed. enter image description here
I've got it, I just need to uninstall werkzeug 2.0.1 and install werkzeug 1.0.1 with the command pip install werkzeug==1.0.1
The werkzeug version listed in the requirements.txt file is0.16.1:
Werkzeug==0.16.1
It is preferable to use the same version

Debuggers throwing "ModuleNotFoundError: No module named 'werkzeug.wrappers.json'; 'werkzeug.wrappers' is not a package"

A piece of code that worked fine in the past now throws the error
ModuleNotFoundError: No module named 'werkzeug.wrappers.json'; 'werkzeug.wrappers' is not a package
whenever I issue the command
from flask import Flask
while developing and debugging.
This even happens in the Flask __init__.py script if I run it in either the Spyder or VSCode debuggers.
Weirdly my Flask application still runs when I flask run from the console (Anaconda) and navigate my website.
The working directories all look OK, and I never had this problem before, I can't debug anymore.
I don't know if this is relevant but I uninstalled flask-bootstrap last week, and I notice that when I now try to upgrade flask with pip or conda I get error message ImportError: cannot import name 'PackageFinder' from 'pip._internal.index'.
Can anyone suggest anything.
MORE DETAILS
I am running a typical Flask application. Here is the console when I start my app, I can go to localhost:5000 and it works.
This console is running an __init__() function that loads up Flask and other dependencies, this script starts like so.
When I go to either the Spyder or VSCode debugger and run the same __init__() script I immediately get the error in the title, this.
It fails on the from flask import... statement trying to load werkzeug packages, Flask is built on jinja2 and werkzeug.
This all worked fine before, the only thing I have done is pip uninstall flask-bootstrap, and bootstrap is showing in error messages whenever I now use pip.
Try uninstalling Flask by running pip uninstall Flask and then installing it again by running pip install Flask --no-cache-dir
Also, the command to upgrade an existing package is pip install -U <package_name> or pip install --upgrade <package_name>

I cant install Flask

I am trying to install flask but everytime i get this error
ModuleNotFoundError: No module named 'flask'. I have added python to path and have even reinstalled it but it just isnt working. I followed steps of activating virtual environment and using pip install flask but it still doesn't seem to work. I need to get my a level coursework completed in a week! Please help.
To check if you have actually installed flask, try this command:pip freeze then check if it is actually listed.
Normal procedure to start a flask app would be:
- create a virtual environment.Make sure you are using python 3. check by using this command. python --version. It should print out the latest version.
- Install Flask. For good measure you could use pip3 to make sure you are using python3.
pip3 install Flask
- Run your app.
I can't tell what OS you're using, so I'll make a recommendation for you that's pretty easy to set up on the majority of OS's/Distros:
If you're really in a pinch use Anaconda.
I find Conda (Anaconda) quite nice for managing python pip environments.
Get it working in your operating system, then pip install Flask in a new Conda environment. This is a useful cheatsheet for Conda.
Once you've activated the environment for your Flask project development should be a breeze.
Good luck.

Local development of Google App Engine not importing built-in library

I followed the quickstart then I simply clone hello_world from here. I already downloaded google_appengine sdk from here. I extract it and now I have folder google_appengine alongside with hello_world
so I execute it like this:
It runs well apparently, until I start to request to localhost:8080.
then I got this error:
what's wrong with it? did I miss something?
google said that I can use the built-in library without manually install it with pip.
PS: it works when I just deploy it to my project on Google. and also it works if I manually install webapp2 inside lib inside hello_world like described here then request it locally.
my python version Python 2.7.6 on ubuntu 14.04 32bit
Please if anybody can solve this I would be appreciate it.
Seems like this is acknowledged bug in app engine SDK. As a temporary workaround, you may try this steps:
Uninstalling the following PIP packages resolved this issue for me.
sudo pip uninstall gcloud
sudo pip uninstall googleapis-common-protos
sudo pip uninstall protobuf
Credit to this thread:
https://groups.google.com/forum/?hl=nl#!topic/google-appengine/LucknWk8iaQ
Be sure to use correct executable of pip if you use virtualenv or have multiple python versions installed.
Thanks to #Dmytro Sadovnychyi for the answer. It doesn't work for me to uninstall those packages because I never installed it before, But that makes me think maybe built-in library conflict with other package so I decide to create Virtual Environment. just fresh environment no need to install any package.
activate the environment then execute dev_appserver.py hello_world now it works
for now I'll stick with it until next update like said here

Categories

Resources