This is what I get every time I want to install any package via apt and make && make install:
Setting up pgadmin4-apache2 (4.23-1.pgdg18.04+1) ...
Traceback (most recent call last):
File "setup.py", line 18, in <module>
from pgadmin.model import db, User, Version, ServerGroup, Server, \
File "/usr/share/pgadmin4/web/pgadmin/__init__.py", line 19, in <module>
from flask import Flask, abort, request, current_app, session, url_for
ModuleNotFoundError: No module named 'flask'
dpkg: error processing package pgadmin4-apache2 (--configure):
installed pgadmin4-apache2 package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
pgadmin4-apache2
E: Sub-process /usr/bin/dpkg returned an error code (1)
I have flask installed:
$ which flask
/home/anna/.local/bin/flask
$ whereis flask
flask: /usr/bin/flask /usr/local/bin/flask /home/anna/.local/bin/flask
$ python -m flask --version
Python 2.7.17
Flask 1.1.2
Werkzeug 1.0.1
but:
$ python3 -m flask --version
/usr/local/bin/python3: No module named flask
tried to install flask by both pip and pip3:
$ pip3 install flask
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: flask in /home/anna/.local/lib/python3.6/site-packages (1.1.2)
Requirement already satisfied: click>=5.1 in /home/anna/.local/lib/python3.6/site-packages (from flask) (7.1.2)
Requirement already satisfied: itsdangerous>=0.24 in /home/anna/.local/lib/python3.6/site-packages (from flask) (1.1.0)
Requirement already satisfied: Jinja2>=2.10.1 in /home/anna/.local/lib/python3.6/site-packages (from flask) (2.11.2)
Requirement already satisfied: Werkzeug>=0.15 in /home/anna/.local/lib/python3.6/site-packages (from flask) (1.0.1)
Requirement already satisfied: MarkupSafe>=0.23 in /home/anna/.local/lib/python3.6/site-packages (from Jinja2>=2.10.1->flask) (1.1.1)
What can I do to fix that?
UPD: I removed pgadmin4-apache2 and it worked!
try this :
sudo pip3 install flask
or
python3 -m pip install flask
as you are getting site-package is not writeable, with sudo you are super user
You can also work in python3 environment and install packages there only.
As #Bramhesh mentioned using apt is the wrong way to go.
Normally you should use:
pip3 install flask
To check your already installed modules use:
pip3 freeze
Sometimes you run into errors during installation e.g. when you don't have write rights in the direction your python environment is saved.
Then use:
sudo pip3 install flask
But as it seems you already have a flask module installed. You can upgrade this by using:
pip3 install flask --upgrade
Cheers!
Related
I am trying to install django using pipenv but failing to do so.
pipenv install django
Creating a virtualenv for this project...
Pipfile: /home/djangoTry/Pipfile
Using /usr/bin/python3.9 (3.9.5) to create virtualenv...
⠴ Creating virtual environment...RuntimeError: failed to query /usr/bin/python3.9 with code 1 err: 'Traceback (most recent call last):\n File "/home/.local/lib/python3.6/site-packages/virtualenv/discovery/py_info.py", line 16, in <module>\n from distutils import dist\nImportError: cannot import name \'dist\' from \'distutils\' (/usr/lib/python3.9/distutils/__init__.py)\n'
✘ Failed creating virtual environment
[pipenv.exceptions.VirtualenvCreationException]:
Failed to create virtual environment.
Other info
python --version
Python 2.7.17
python3 --version
Python 3.6.9
python3.9 --version
Python 3.9.4
pip3 --version
pip 21.1 from /home/aman/.local/lib/python3.6/site-packages/pip (python 3.6)
Please help.Thanks
The problem isn't with installing Django, is on creating your venv, I don't create on this way so I will pass the way that i create
Step 1 - Install pip
Step 2 - Install virtaulEnv
check here how to install both
after installed, run python3 -m venv venvthis wil create an venv on your current directory. Initiate them with . venv/bin/activateand so run pip install django. That should work
Try pipenv install --python 3.9
For some reasons I removed Django
first I entered
>> import django
>> django.__path__
and then I entered
sudo rm -r path
in terminal.
And now when I'm trying to reinstall it I enter these commands
$ sudo apt-get update
$ sudo apt-get install python3-django
i see
Reading package lists... Done
Building dependency tree
Reading state information... Done
python3-django is already the newest version (1:1.11.11-1ubuntu1.8).
0 upgraded, 0 newly installed, 0 to remove and 5 not upgraded.
And then I enter
django-admin --version
i see
Traceback (most recent call last):
File "/usr/local/bin/django-admin", line 5, in
from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django'
What should I do to reinstall it?
You can try to install Django using this command:
pip3 install Django
Like how we have pip install <filename> to install a package.
Similarly, to uninstall a package, you can do pip uninstall <filename>
in your case,
to install Django : pip install django
to Uninstall Django : pip uninstall django
OS : Ubuntu 16.04
Python 2.7
pip list | grep gev
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
gevent (1.3a2)
Just to make sure, I checked:
pip install --upgrade gevent
Requirement already up-to-date: gevent in /home/user/.local/lib/python2.7/site-packages
Requirement already up-to-date: greenlet>=0.4.13; platform_python_implementation == "CPython" in /home/user/.local/lib/python2.7/site-packages (from gevent)
However when I actually run my python program it bails out with an error:
import gevent
ImportError: No module named gevent
Please advise.
Stuff I already tried:
pip --version
pip 9.0.1 from /home/user/.local/lib/python2.7/site-packages (python 2.7)
python -m pip install --user gevent
Requirement already satisfied: gevent in /home/user/.local/lib/python2.7/site-packages
Requirement already satisfied: greenlet>=0.4.13; platform_python_implementation == "CPython" in /home/user/.local/lib/python2.7/site-packages (from gevent)
which -a python
/usr/bin/python
/usr/bin/python
along with things mentioned here:
https://github.com/PokeAlarm/PokeAlarm/issues/22
I also tried uninstalling the pip installation and doing apt-get :
sudo apt-get install python-gevent python-gevent-websocket
mentioned here: https://askubuntu.com/questions/836029/importerror-no-module-named-gevent/1013457#1013457
Working in a Python virtual environment in Ubuntu 16.04 I got the following results:
$ python -m pip install gevent
Requirement already satisfied: gevent in ./lib/python2.7/site-packages
Requirement already satisfied: greenlet>=0.4.10 in ./lib/python2.7/site-packages (from gevent)
import gevent worked successfully in my Python virtual environment, but it did not work outside of my Python virtual environment until I ran the following command:
sudo apt install python-gevent # also works in all currently supported versions of Ubuntu
Description: gevent is a coroutine-based Python networking library. gevent uses greenlet to provide a high-level synchronous API on top of libevent event loop.
You can also install python3-gevent for Python 3.x in all currently supported versions of Ubuntu by running the following command:
sudo apt install python3-gevent
make sure that your pip references the same python that you are using,
on many systems you can have multiple python versions installed.
you can see which to which python your pip belongs by running:
pip --version
enter image description here
goto anaconda navigator and select the environment on which you are working ...then select not installed ,check for gevent and install
When I try to run my server using:
./manage.py runserver 0.0.0.0:8000
I get the following error:
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
from django.core.management import execute_from_command_line
ImportError: No module named django.core.management
After browsing for a solution, I learned that Django was not installed so I tried installing it on a VM.
I tried the following:
pip install django
yum install django
yum install python-django
I also tried running these commands with sudo -s and sudo -E.
I am getting the following when I use pip cmd:
Downloading/unpacking django
Cannot fetch index base URL https://pypi.python.org/simple/
Could not find any downloads that satisfy the requirement django
No distributions at all found for django
Storing complete log in /root/.pip/pip.log
Using Yum I get:
No package python-django available.
Error: Nothing to do
Install a new version of Python. Pip has to be installed for the new
version. CentOS 6.6 has default Python 2.6 and the default pip
doesn't work properly.
Install Django with new pip.
Do not install the new version of Python globally as CentOS relies on
Python 2.6 for yum.
I've been doing the following tutorial and looking it over may help you figure out what I haven't been able to:
http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world/
I'm working on a OS X (10.6.8) with Python 2.7.6. I'm pretty sure that I followed all the instructions (on page 1) to a T and have checked that the required libraries are indeed in the modules list in the python virtualenv however, I get this error message when I try to run 'run.py':
File "/Users/user1/Desktop/flasktut/microblog/flask/lib/python2.7/site-packages/jinja2/utils.py", line 520, in <module>
from markupsafe import Markup, escape, soft_unicode
ImportError: No module named markupsafe
I need markupsafe in my virtualenv - how do I get it in there?
The command to check what packages you have installed is:
$ pip freeze
If you don't see an entry for MarkupSafe there then you can install it with:
$ pip install markupsafe