<Windows> How to pipenv install djangorestframework - python-3.x

My Environment: Windows10 64, Python 3.7, Django 2.2, IDE: VSC
I installed env and activated. I am trying to install djangorestframework with the command
pipenv install djangorestframework
Error:
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', timeout('_ssl.c:1074: The handshake operation timed out'))': /simple/djangorestframework/
ERROR: Could not find a version that satisfies the requirement djangorestframework
ERROR: No matching distribution found for djangorestframework
Here is what I have installed in my env.
python -m pip list
Package Version
------------------- -------
astroid 2.4.2
colorama 0.4.4
Django 2.2
isort 5.6.4
lazy-object-proxy 1.4.3
mccabe 0.6.1
pip 20.3
pylint 2.6.0
pylint-django 2.3.0
pylint-plugin-utils 0.6
pytz 2020.4
setuptools 50.3.2
six 1.15.0
sqlparse 0.4.1
toml 0.10.2
typed-ast 1.4.1
wheel 0.35.1
wrapt 1.12.1
When I existed env and tried pip install djangorestframe, it worked. What did I miss in env? Please help me install this framework. Thank you.

try upgrading your pip type
python -m pip install --upgrade pip

use this instead of other one
pipenv install rest_framework

According to this link: https://dev.to/habibaudu/simple-rest-api-with-django-rest-framework-4bmc
You can install django-rest-framework using pipenv using this:
pipenv install djangorestframework
Then you should add the django-rest-framework to the INSTALLED_APPS in settings.py file.
INSTALLED_APPS = [ 'django.contrib.admin', 'rest_framework', ]

Related

How to delete all packages from my ubuntu terminal in windows 10?

I have all these packages and I would like to remove them (removing pip and apache-airflow is my priority)
alembic 1.8.1
anyio 3.6.2
apache-airflow 2.4.2
apache-airflow-providers-common-sql 1.2.0
apache-airflow-providers-ftp 3.1.0
apache-airflow-providers-http 4.0.0
apache-airflow-providers-imap 3.0.0
apache-airflow-providers-sqlite 3.2.1
apispec 3.3.2
argcomplete 2.0.0
attrs 22.1.0
Babel 2.11.0
blinker 1.4
cachelib 0.9.0
cattrs 22.2.0
certifi 2022.9.24
charset-normalizer 2.1.1
pendulum 2.1.2
pip 22.0.2
pluggy 1.0.0
prison 0.2.1
psutil 5.9.4
Pygments 2.13.0
PyGObject 3.42.1
PyJWT 2.3.0
pyparsing 2.4.7
pyrsistent 0.19.2
python-apt 2.3.0+ubuntu2.1
python-daemon 2.3.2
python-dateutil 2.8.2
python-nvd3 0.15.0
python-slugify 6.1.2
pytz 2022.6
pytzdata 2020.1
PyYAML 5.4.1
requests 2.28.1
requests-toolbelt 0.10.1
rfc3986 1.5.0
uc-micro-py 1.0.1
ufw 0.36.1
Download ubuntu console for windows 10 and install pip and apache airflow without creating an environment (my mistake)
I run pip freeze --user | xargs pip uninstall -y to remove all and I get this error:
ERROR: Exception:
Traceback (most recent call last):
File "/usr/lib/python3.10/shutil.py", line 815, in move
os.rename(src, real_dst)
PermissionError: [Errno 13] Permission denied: '/usr/local/bin/alembic' -> '/tmp/pip-uninstall- lj7qg0bv/alembic'
If you're sure you really need to uninstall packages installed under /usr/local/ use superuser privileges:
pip freeze --user | xargs sudo pip uninstall -y

Python3 flask ModuleNotFoundError: No module named 'blurhash' error

I am new to Python. Recently, I am using Python 3.9.12 and Flask 2.1.2 to work on a project. When I run flask run, it throw me an error: ModuleNotFoundError: No module named 'blurhash'.However I have installed blurhash by pip3 install blurhash. When I do pip3 list, it shows:
Package Version
------------------ ---------
blurhash 1.1.4
certifi 2021.10.8
cffi 1.15.0
click 8.1.3
distlib 0.3.4
filelock 3.6.0
Flask 2.1.2
importlib-metadata 4.11.3
itsdangerous 2.1.2
Jinja2 3.1.2
MarkupSafe 2.1.1
Pillow 9.1.0
pip 22.0.4
pipenv 2022.5.2
platformdirs 2.5.2
pycparser 2.21
setuptools 60.10.0
six 1.16.0
virtualenv 20.14.1
virtualenv-clone 0.5.7
Werkzeug 2.1.2
wheel 0.37.1
zipp 3.8.0
Any ideas about this? Many Thanks!

Install Tensorflow 2.2 on linux

I have GNU/Linux box, I am trying to install Tensorflow 2.2. Currently I have
python3.6 --version
Python 3.6.12
and when I try to run my code it says
ImportError: Keras requires TensorFlow 2.2 or higher. Install TensorFlow via `pip install tensorflow`
So when I try to install Tensorflow 2.2
sudo pip-3.6 install --upgrade tensorflow==2.2.0
Collecting tensorflow==2.2.0
Could not find a version that satisfies the requirement tensorflow==2.2.0 (from versions: 0.12.1, 1.0.0, 1.0.1, 1.1.0rc0, 1.1.0rc1, 1.1.0rc2, 1.1.0, 1.2.0rc0, 1.2.0rc1, 1.2.0rc2, 1.2.0, 1.2.1, 1.3.0rc0, 1.3.0rc1, 1.3.0rc2, 1.3.0, 1.4.0rc0, 1.4.0rc1, 1.4.0, 1.4.1, 1.5.0rc0, 1.5.0rc1, 1.5.0, 1.5.1, 1.6.0rc0, 1.6.0rc1, 1.6.0, 1.7.0rc0, 1.7.0rc1, 1.7.0, 1.7.1, 1.8.0rc0, 1.8.0rc1, 1.8.0, 1.9.0rc0, 1.9.0rc1, 1.9.0rc2, 1.9.0, 1.10.0rc0, 1.10.0rc1, 1.10.0, 1.10.1, 1.11.0rc0, 1.11.0rc1, 1.11.0rc2, 1.11.0, 1.12.0rc0, 1.12.0rc1, 1.12.0rc2, 1.12.0, 1.12.2, 1.12.3, 1.13.0rc0, 1.13.0rc1, 1.13.0rc2, 1.13.1, 1.13.2, 1.14.0rc0, 1.14.0rc1, 1.14.0, 2.0.0a0, 2.0.0b0, 2.0.0b1)
No matching distribution found for tensorflow==2.2.0
I get the above error. Any idea how to fix this issue?
Update:
sudo pip-3.6 --version
pip 9.0.3 from /usr/lib/python3.6/dist-packages (python 3.6)
-Raj
Starting with Tensorflow 2.0 Google stopped providing manylinux1 wheels and switched to manylinux2010 which is probably not recognized by your pip because it's too old. Try to upgrade: sudo pip-3.6 install -U pip, then verify sudo pip-3.6 --version and retry sudo pip-3.6 install -U tensorflow==2.2.0
TensorFlow 2 packages require a pip version >19.0.
https://www.tensorflow.org/install

pip install in virtualenv on EC2 missing packages in requirements.txt file on install

I am pip installing a variety of packages inside a virtual environment on an EC2 instance (2018-03). Pip successfully installs some of the packages, but not all. I am using pip install --force-reinstall -r requirements.txt on the following requirements file, which was created on a system with a working instance with Python 3.7.4 on Macos:
alembic==1.1.0
bcrypt==3.1.7
boto3==1.9.156
botocore==1.12.249
certifi==2019.9.11
cffi==1.12.3
chardet==3.0.4
Click==7.0
coverage==4.5.4
docutils==0.15.2
Flask==1.0.2
Flask-Bcrypt==0.7.1
Flask-Login==0.4.1
Flask-Migrate==2.5.2
Flask-Script==2.0.6
Flask-Session==0.3.1
Flask-SQLAlchemy==2.4.0
Flask-WTF==0.14.2
idna==2.8
itsdangerous==1.1.0
Jinja2==2.10.1
jmespath==0.9.4
lxml==4.3.2
Mako==1.1.0
MarkupSafe==1.1.1
numpy==1.16.2
pandas==0.24.2
patsy==0.5.1
psycopg2==2.8.3
pycparser==2.19
python-dateutil==2.8.0
python-editor==1.0.4
pytz==2019.2
requests==2.21.0
s3transfer==0.2.1
scikit-learn==0.20.3
scipy==1.2.1
six==1.12.0
SQLAlchemy==1.3.8
statsmodels==0.9.0
trimesh==3.1.11
urllib3==1.24.3
Werkzeug==0.15.5
WTForms==2.2.1
And pip gives me the following message:
Successfully installed Click-7.0 Flask-1.0.2 Flask-Bcrypt-0.7.1 Flask-Login-0.4.1 Flask-Migrate-2.5.2 Flask-SQLAlchemy-2.4.0 Flask-Script-2.0.6 Flask-Session-0.3.1 Flask-WTF-0.14.2 Jinja2-2.10.1 Mako-1.1.0 MarkupSafe-1.1.1 SQLAlchemy-1.3.8 WTForms-2.2.1 Werkzeug-0.15.5 alembic-1.1.0 bcrypt-3.1.7 boto3-1.9.156 botocore-1.12.249 certifi-2019.9.11 cffi-1.12.3 chardet-3.0.4 coverage-4.5.4 docutils-0.15.2 idna-2.8 itsdangerous-1.1.0 jmespath-0.9.4 lxml-4.3.2 numpy-1.16.2 pandas-0.24.2 patsy-0.5.1 psycopg2-2.8.3 pycparser-2.19 python-dateutil-2.8.0 python-editor-1.0.4 pytz-2019.2 requests-2.21.0 s3transfer-0.2.1 scikit-learn-0.20.3 scipy-1.2.1 six-1.12.0 statsmodels-0.9.0 trimesh-3.1.11 urllib3-1.24.3
However when I do a pip list I only see the following packages installed. Note that coverage and psycopg2, for example, were listed as successfully installed, but don't show. Consequently, a quick python -c "import coverage" will fail.
Package Version
---------------- ---------
alembic 1.1.0
boto3 1.9.156
botocore 1.12.249
certifi 2019.9.11
chardet 3.0.4
Click 7.0
docutils 0.15.2
Flask 1.0.2
Flask-Bcrypt 0.7.1
Flask-Login 0.4.1
Flask-Migrate 2.5.2
Flask-Script 2.0.6
Flask-Session 0.3.1
Flask-SQLAlchemy 2.4.0
Flask-WTF 0.14.2
idna 2.8
itsdangerous 1.1.0
Jinja2 2.10.1
jmespath 0.9.4
Mako 1.1.0
patsy 0.5.1
pip 19.3.1
pycparser 2.19
python-dateutil 2.8.0
python-editor 1.0.4
pytz 2019.2
requests 2.21.0
s3transfer 0.2.1
setuptools 41.6.0
six 1.12.0
trimesh 3.1.11
urllib3 1.24.3
Werkzeug 0.15.5
wheel 0.33.6
WTForms 2.2.1
My questions are:
Are there ways to resolve with pip options other than --force-reinstall and --no-cache-dir, which I have already tried?
Could my issue relate to the fact that the latest supported package of Python I can grab on EC2 is 3.6.8, but my requirements.txt file was created on a 3.7.4 system? (Yes yes, I know, next time I'll be wiser and just use docker from the start.)
After much hand-wringing and nearly doing Docker bootcamp, I decided to go back for another round and found the underlying problem. Inside my virtual environment, I noticed that pip list was only listing packages as listed in the $MYENV/lib/Python3.6/data/dist-packages, whereas the offending packages were all located in $MYENV/lib64/Python3.6/data/dist-packages. This led to some additional searching and this response, which suggests symlinking the lib64 version of dist-packages to the lib version, which did the trick and resolved my issue. I'm using pip version 19.3.1, and the referenced article is from over 2 years ago, so I will definitely be talking to some folks.
However, for those who want the quick solution, here are the steps.
Fresh virtual environment: Set up a fresh virtual environment as you normally would.
Symlink BEFORE pip: Do your symlinking before you start installing any packages. Generally this will look something like:
ln -s $YOURENV/lib/Python3.x/data/dist-packages $YOURENV/lib64/Python3.x/data/dist-packages
Go ahead and pip: No you can pip install -r requirements.txt as you normally would. Double-check with a pip list and you should see all your packages listed.

Error When Connecting to MongoDB on Atlas Using Python3 and MongoAlchemy

I am connecting to a cluster set up on MongoDB Atlas using the connection string given on the site.
I am running python3 and then run the import db from my module.
I get the error "pymongo.errors.InvalidURI: Invalid URI scheme: mongodb+srv"
My code looks like:
app.config["MONGOALCHEMY_DATABASE"] = "<CLUSTER NAME>"
app.config["MONGOALCHEMY_CONNECTION_STRING"] = "mongodb+srv://<REST OF URL GIVEN"
My install list looks as:
Package Version
bcrypt 3.1.7
cffi 1.12.3
Click 7.0
Flask 1.1.0
Flask-Bcrypt 0.7.1
Flask-Login 0.4.1
Flask-MongoAlchemy 0.7.2
Flask-PyMongo 0.5.2
Flask-SQLAlchemy 2.4.0
Flask-WTF 0.14.2
itsdangerous 1.1.0
Jinja2 2.10.1
MarkupSafe 1.1.1
MongoAlchemy 0.19
pip 19.1.1
pkg-resources 0.0.0
pycparser 2.19
pymongo 2.8.1
setuptools 41.0.1
six 1.12.0
SQLAlchemy 1.3.5
Werkzeug 0.15.4
wheel 0.33.4
WTForms 2.2.1
It seems to work now since I installed an earlier version with pip3 install Flask-MongoAlchemy==0.7.1
It now seems to connect, but I am running into other problems now.

Resources