File “/usr/bin/pip”, line 9, in from pip import main ImportError: cannot import name main

TL;DR The ‘ideal’ solution (Ubuntu/Debian way):$ python -m pip uninstall pip to uninstall the new pip 10 and retain your Ubuntu/Debian-provided patched pip 8. For a system-wide installation of modules use apt wherever possible (unless you are in a virtualenv), more on it below. In older Ubuntu/Debian versions, always add –user flag when using pip outside of virtualenvs (installs into ~/.local/, default in … Read more

How to get POSTed JSON in Flask?

First of all, the .json attribute is a property that delegates to the request.get_json() method, which documents why you see None here. You need to set the request content type to application/json for the .json property and .get_json() method (with no arguments) to work as either will produce None otherwise. See the Flask Request documentation: … Read more

python-How to set global variables in Flask?

With: You are not defining, just declaring so it’s like saying there is a global index_add_counter variable elsewhere, and not create a global called index_add_counter. As you name don’t exists, Python is telling you it can not import that name. So you need to simply remove the global keyword and initialize your variable: Now you can import it with: The construction: is used … Read more

How do I get Flask to run on port 80?

So it’s throwing up that error message because you have apache2 running on port 80. If this is for development, I would just leave it as it is on port 5000. If it’s for production either: Not Recommended Stop apache2 first; Not recommended as it states in the documentation: You can use the builtin server during development, but you … Read more

tech