Installing TensorFlow with pipenv gives error - python

I'm trying to install TensorFlow using pipenv.
This is my Pipfile:
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
pylint = "*"
[packages]
python-telegram-bot = "*"
imdbpy = "*"
matplotlib = "*"
scikit-image = "*"
scikit-learn = "*"
tensorflow = "*"
[requires]
python_version = "3.8"
I then run:
pipenv install tensorflow
Which outputs:
Installing tensorflow…
Adding tensorflow to Pipfile's [packages]…
Installation Succeeded
Pipfile.lock (989c3d) out of date, updating to (0d6760)…
Locking [dev-packages] dependencies…
Success!
Locking [packages] dependencies…
Locking Failed!
Followed by a big traceback that ends with:
pipenv.patched.notpip._internal.exceptions.InstallationError: Command "python setup.py egg_info" failed with error code 1 in C:\Users\lucas\AppData\Local\Temp\tmpyh639mq4build\functools32\
My virtual environment uses Python 3.8.0 64 bit.
What am I doing wrong?

As the comments pointed out, Tensorflow only supports up to python 3.7 (as March 2020). You can find more info in the system requirements page of the documentation.
So, to fix your issue:
Remove the virtual environment with pipenv --rm
Remove the Pipfile.lock
Change the last lines of your Pipfile to
[requires]
python_version = "3.7"
Run pipenv install --dev to recreate the environment again and pipenv install tensorflow to install tensorflow
Done!

Related

How to install Python packes listed in `Pipfile` using `pipenv` and the `--target` flag (via `--extra-pip-args`)?

A) The following does not install the packages from Pipfile into the --target directory foo:
pipenv install --extra-pip-args="--target=foo"
B) On the other hand, this does install the explicitly specified package(s) (request in this case) into the --target directory foo:
pipenv install --extra-pip-args="--target=foo" requests
How can I make the first command work? It would be preferable, as Pipfile already has version-pinned packages listed:
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
requests = "2.28.2"
[dev-packages]
[requires]
python_version = "3.9"

pipenv install of packages failing: pointer is missing a nullability type specifier (_Nonnull, _Nullable

I’m having this weird issue with a virtual environment that is making me nuts
This is what I’ve tried so far. Maybe more options, but
Changed ipdb to dev packages
Updated pipfile
#### EXPLODED HERE ####
pipenv update
pipenv install
brew update
brew upgrade
==> Upgrading pipenv
2022.9.24 -> 2022.12.19
#### EXPLODED HERE AGAIN #### pipenv install | pipenv install --dev
git reset HARD to take back the commit (I even reverted the commit on git to be able to merge) --> this worked for Git, but not for my local
Removed virtualenv and tried again
pipenv shell
pipenv shell --python 3.9
pipenv install --dev
pipenv install pytest ### FAILED ###
pipenv install aenum ### FAILED ###
pipenv install aiohttp==3.8.1 ### FAILED ###
Docker build . #### ALSO FAILED ####
retry pipenv operations ### FAILED ###
The issue seems always the same, I copy a summary of the logs. Since the error log is HUGE. I just paste what seems more important.
NOTE: I found out that the package that is failing is pytest (I tried varius versions from 7.1.x to 7.2.x..)
0190253ad770c5df17db1 --hash=sha256:5cf820485f1b4c91e0417ea0afd41ce5cf5965011b3c22c400f6d144296ccbc0! Will try again.
An error occurred while installing ftfy==6.1.1 --hash=sha256:bfc2019f84fcd851419152320a6375604a0f1459c281b5b199b2cd0d2e727f8f --hash=sha256:0ffd33fce16b54cccaec78d6ec73d95ad370e5df5a25255c8966a6147bd667ca! Will try again.
An error occurred while installing gensim==4.3.0 --hash=sha256:e83d8ce322d6a3a93228944aba95e6951769d5238d49b6c5b89ad2515a56a136 --
An error occurred while installing decorator==5.1.1 ; python_version > '3.6' and python_version < '3.11' --hash=sha256:b8c3f85900b9dc423225913c5aace94729fe1fa9763b38939a95226f02d37186 --hash=sha256:637996211036b6385ef91435e4fae22989472f9d571faba8927ba8253acbc330! Will try again.
An error occurred while installing et-xmlfile==1.1.0 ; python_version >= '3.6' --hash=sha256:8eb9e2bc2f8c97e37a2dc85a09ecdcdec9d8a396530a6d5a33b30b9a92da0c5c --hash=sha256:a2ba85d1d6a74ef63837eed693bcb89c3f752169b0e3e7ae5b16ca5e1b3deada! Will try again.
An error occurred while installing fonttools==4.38.0 ; python_version >= '3.7' --hash=sha256:820466f43c8be8c3009aef8b87e785014133508f0de64ec469e4efb643ae54fb --hash=sha256:2bb244009f9bf3fa100fc3ead6aeb99febe5985fa20afbfbaa2f8946c2fbdaf1! Will try again.
An error occurred while installing frozenlist==1.3.3 ; python_version >= '3.7' --hash=sha256:f20380df709d91525e4bee04746ba612a4df0972c1b8f8e1e8af997e678c7b81 --
An error occurred while installing cycler==0.11.0 ; python_version >= '3.6' --hash=sha256:3a27e95f763a428a739d2add979fa7494c912a32c17c4c38c4d5f082cad165a3 --hash=sha256:9c87405839a19696e837b3b818fed3f5f69f16f1eec1a1ad77e043dcea9c772f! Will try again.
An error occurred while installing cython==0.29.33 --hash=sha256:f271f90005064c49b47a93f456dc6cf0a21d21ef835bd33ac1e0db10ad51f84f --
An error occurred while installing aiohttp==3.8.1 --hash=sha256:086f92daf51a032d062ec5f58af5ca6a44d082c35299c96376a41cbb33034675 --hash=sha256:6f8b01295e26c68b3a1b90efb7a89029110d3a4139270b24fda961893216c440 --hash=sha256:99b5eeae8e019e7aad8af8bb314fb908dd2e028b3cdaad87ec05095394cce632 --hash=sha256:eaba923151d9deea315be1f3e2b31cc39a6d1d2f682f942905951f4e40200922 --
[1:22 PM] Installing dependencies from Pipfile.lock (e0f6e8)...
An error occurred while installing aenum==3.1.11 --hash=sha256:12ae89967f2e25c0ce28c293955d643f891603488bc3d9946158ba2b35203638 --hash=sha256:aed2c273547ae72a0d5ee869719c02a643da16bf507c80958faadc7e038e3f73 --hash=sha256:525b4870a27d0b471c265bda692bc657f1e0dd7597ad4186d072c59f9db666f6! Will try again.
An error occurred while installing aiohttp==3.8.1 --hash=sha256:2f2f69dca064926e79997f45b2f34e202b320fd3782f17a91941f7eb85502ee2 --
My Pipfile
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
awswrangler = "*"
pandas = "*"
beautifulsoup4 = "*"
fake-headers = "*"
geopy = {extras = ["aiohttp"], version = "*"}
geotext = "*"
langid = "*"
tqdm = "*"
pytest = "*"
joblib = "*"
cython = "*"
gensim = "*"
opensearch-py = "*"
ftfy = "*"
sparse-dot-topn = "*"
scikit-learn = "*"
polyfuzz = "*"
[dev-packages]
pytest = "*"
pylint = "*"
pytest-mock = "*"
pytest-asyncio = "*"
pip = "*"
install = "*"
freezegun = "*"
ipython = "*"
wikidata = "*"
pyhamcrest = "*"
[requires]
python_version = "3.9"

Docker not recognising psycopg2-binary as psycopg2

Using pipenv I have the following pipfile:
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
flask = "*"
uuid = "*"
gunicorn = "*"
psycopg2-binary = "*"
[dev-packages]
[requires]
python_version = "3.8"
And then my Dockerfile is set up as follows:
FROM python:3.8.3-slim-buster
RUN useradd deploy_trial
WORKDIR /home/deploy_trial
RUN pip install pipenv
COPY . /home/deploy_trial/
RUN pipenv install --deploy
CMD ["python","./app/text.py"]
However, although the build seems to go successfully, when I run the image I get an error message saying:
Traceback (most recent call last):
File "./app/text.py", line 1, in <module>
import psycopg2
ModuleNotFoundError: No module named 'psycopg2'
So it obviously thinks that psycopg2 hasn't been installed... This is really strange because when I have used psycopg2-binary on my local machine and all of my programs there recognise the installation as psycopg2 when the code is run. Does anyone know how to fix this?
My dockerfile:
FROM python:3.8.3-slim-buster
RUN python -m pip install pipenv
COPY script.py script.py
COPY Pipfile Pipfile
RUN pipenv install
CMD ["pipenv", "run", "python", "script.py"]
script.py:
import psycopg2
print('it is ok')
Pipfile:
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
psycopg2-binary = "*"
[dev-packages]
[requires]
python_version = "3.8"
It works with such configuration.

Python quit unexpectedly after `pipenv install`

I am trying to install dependencies with pipenv install and receive modal letting me know that Python quit unexpectedly:
I have uninstalled python, and installed from https://www.python.org/downloads/ (not using homebrew)
Python version: 3.9.9 ;
OS: Monterey 12.0.1
Pipfile:
url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"
[packages]
Flask = "==2.0.2"
flask-marshmallow = "==0.14.0"
Flask-SQLAlchemy = "==2.5.1"
marshmallow-sqlalchemy = "==0.26.1"
Flask-Migrate = "==3.1.0"
pytest = "==6.2.5"
pytest-testdox = "==2.0.1"
black = "==21.9b0"
pylint = "==2.11.1"
pylint-flask-sqlalchemy = "==0.2.0"
[dev-packages]
[requires]
python_version = "3.9"
Terminal output after command:
Pipfile.lock not found, creating...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
Building requirements...
Resolving dependencies...
✘ Locking Failed!
WARNING: /Library/Frameworks/Python.framework/Versions/3.9/Resources/Python.app/Contents/MacOS/Python is loading libcrypto in an unsafe way
Could the problem be indicated by the failed locking? or loading libcrypto in an unsafe way?
Any one else run into something similar? Anything to try to resolve?
Thanks all
Adding sudo before command removed the error modal .. thank you #Josh Sharkey

python pip: cannot install flask and zappa - contradicting requirements

I want to install flask and zappa, a common combination.
I use pipenv to create an evironment:
pipenv --python 3.6.4
I want to install packages:
pipenv install flask zappa
Unfortunately the requirements of flask is:
Werkzeug >= 0.14
the requirement of zappa is :
Werkzeug == 0.12
So this is not installable. What can i do?
Thanks to Evgeny this solution was successful. I could not find it in pipenv documentation.
Just manually edit the Pipfile:
Pipfile
[[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"
[dev-packages]
[packages]
zappa = { git = 'https://github.com/Miserlou/Zappa.git', ref = 'master', editable = true }
flask = "*"
[requires]
python_version = "3.6"

Categories