Heroku fails to install dependency - How do I fix it? - python

I'm trying to push an app to Heroku (first time) and it continues to fail when attempting to install on of the dependencies in the requirements.txt file.
The dependency is for the etsy-python library ("pip install etsy" fails).
Locally, I was able to get this to work by downloading and building the source. How can I get past this issue with Heroku?
requirements.txt:
Flask==0.9
Jinja2==2.6
Werkzeug==0.8.3
etsy==0.3.1
geopy==0.94.2
httplib2==0.7.7
oauth2==1.5.211
python-etsy==0.1.2
python-twitter==0.8.4
requests==1.0.4
requests-oauth==0.4.1
simplejson==3.0.4

I was able to fix this by modifying the requirements.txt as follows:
Although the pypi package for Etsy is not working, the source is ok and builds without problems.
Flask==0.9
Jinja2==2.6
Werkzeug==0.8.3
-e git+https://github.com/mcfunley/etsy-python.git#egg=etsy-python
geopy==0.94.2
httplib2==0.7.7
oauth2==1.5.211
python-etsy==0.1.2
-e git+https://github.com/bear/python-twitter.git#egg=python-twitter
requests==1.0.4
requests-oauth==0.4.1
simplejson==3.0.4

I'm getting this error when I try to install etsy locally:
ValueError: Invalid IPv6 URL
I'd say that the official py-etsy is outdated and broken, the Github repo was last updated a year ago: https://github.com/mcfunley/etsy-python. This library is more recent (5 months ago): https://github.com/priestc/python-etsy.
It's not on pypi, but clone it locally and include it in your project.

Related

Unable to find installation candidates for nvidia-cudnn-cu11 when trying to install kornia

I'm trying to install kornia using poetry.
System details
Python 3.8.5 (I have to use this version)
poetry 1.1.13 (upgrading to v1.2 is not an option)
I've previously installed kornia (poetry add kornia) but for some unknown reason I'm now getting the following traceback:
RuntimeError
Unable to find installation candidates for nvidia-cudnn-cu11
(8.5.0.96)
at ~.poetry\lib\poetry\installation\chooser.py:72 in choose_for
68│
69│ links.append(link)
70│
71│ if not links:
→ 72│ raise RuntimeError(
73│ "Unable to find installation candidates for {}".format(package)
74│ )
Since this wasn't a very helpful traceback I thought I'd try to pip install to see if I could get kornia installed somehow, then repeat the process using poetry.
First I ran poetry run pip install nvidia-pyindex, then poetry run pip install kornia. kornia was installed, giving me confidence that I might be able to do the same using poetry.
So I ran poetry add nvidia-pyindex which installed, but when I ran poetry add kornia I got the same RuntimeError.
I wondered if having poetry add without pip uninstall might have caused issues. So I started from scratch - I ran:
rm -rf ~/.cache/pypoetry/cache/repositories/pypi/
poetry rm {name of venv}
git checkout master pyproject.toml poetry.lock
poetry add nvidia-pyindex
which created the venv (by the same name as previously - not sure if this is an issue in itself, since the name of the venv was first created in PyCharm and I wonder if there are some files lingering in places I don't know that is the root of my problems?), then poetry add kornia but got the same error.
I also tried to clear poetry's cache as suggested here but that didn't help. I didn't find a solution here. I don't believe this applies since poetry was installed properly and is working fine otherwise. I read through this but didn't see any working solution. I tried a fix mentioned here, which was to add
[[tool.poetry.source]]
name = "nvidia"
url = "https://pypi.ngc.nvidia.com"
secondary = true
to pyproject.toml, hoping that it would avoid the error when poetry tries to install nvidia-cudnn-cu11, but it didn't help either.
I tried poetry add nvidia-cudnn-cu11 and poetry add nvidia-cudnn-cu116 hoping that having added the ndvidia repo as a secondary source would get kornia's dependencies installed before trying to install kornia itself.
{I don't know if secondary sources are only used when poetry adding a package (i.e. kornia) and "ignored" for installation of dependencies (nvidia-cudnn-cu11) of the package to be installed (kornia).}
In any case, that didn't work either.
Running poetry source add nvidia https://pypi.ngc.nvidia.com didn't work - presumably because poetry source add was added to poetry v1.2 and was not part of v1.1.13.
I also tried poetry add --source nvidia https://pypi.ngc.nvidia.com but I got
PermissionError
[Errno 13] Permission denied:
'C:\Users\...\AppData\Local\Temp\tmp2t6am7ei'
at ~.poetry\lib\poetry\utils\helpers.py:101 in download_file
97│
98│ with get(url, stream=True) as response:
99│ response.raise_for_status()
100│
→ 101│ with open(dest, "wb") as f:
102│ for chunk in response.iter_content(chunk_size=chunk_size):
103│ if chunk:
104│ f.write(chunk)
I'm out of ideas and hoped someone might help.
could this be related to this problem?
https://github.com/python-poetry/poetry/issues/6939
https://github.com/pytorch/pytorch/issues/88049
I had a similar issue and was able to fix it by making the torch dependency explicit and install torch version < 1.13:
[tool.poetry.dependencies]
...
torch = "~1.12.1"

I cannot install Django in my Virtual Environment

I wanted to install Django in my virtual environment (which was completely working), but got this whole lot of errors. Anyone know what to do?
I just typed this in PowerShell:
pipenv install django
And got this:
Error: An error occurred while installing django!
Error text: Collecting django
Using cached Django-3.1.7-py3-none-any.whl (7.8 MB)
ERROR: THESE PACKAGES DO NOT MATCH THE HASHES FROM Pipfile.lock!. If you have updated the package versions, please update the hashes. Otherwise, examine the package contents carefully; someone may have tampered with them.
django from https://files.pythonhosted.org/packages/b8/6f/9a4415cc4fe9228e26ea53cf2005961799b2abb8da0411e519fdb74754fa/Django-3.1.7-py3-none-any.whl#sha256=baf099db36ad31f970775d0be5587cc58a6256a6771a44eb795b554d45f211b8 (from -r c:\users\vojtěch\appdata\local\temp\pipenv-e9otm_0m-requirements\pipenv-sj4h6g3_-requirement.txt (line 1)):
Expected sha256 baf099db36ad31f970775d0be5587cc58a6256a6771a44eb795b554d45f211b8
Got 764ad5e659cd3a7740b314806b39c67501c6136a21d23652515df3bfb4023d76
It looks like your original download may have failed, and pip is using the cached download instead of getting a new one. Try pipenv lock --clear and then pipenv install django again.

Airflow - no module named "airflow.providers" or "airflow.contrib.providers"

We are trying to import both MongoHook and GCSToLocalFilesystemOperator into our Airflow Project:
docs for MongoHook
docs for GCS Operator
...per this post, "Providers package is no longer included with Airflow, but you can separately install them with pip using the specific backport package"
I have had no luck with this. For our DockerFile, we started using this image from the puckel/docker-airflow repo on GitHub.
I've tried adding these two lines to our requirements.txt
apache-airflow-backport-providers-mongo
apache-airflow-backport-providers-google
...and I've tried adding these lines to our DockerFile:
&& pip install apache-airflow-backport-providers-mongo \
&& pip install apache-airflow-backport-providers-google \
...and we're getting the errors mentioned in the title. How can I install these into our docker image/container to use them in our Airflow project?
edit: checking quickly to see if the issue was that I simply wasn't rebuilding the image
edit2: rebuilding the image was needed; however, now we are receiving the error No module named 'airflow.utils.process_utils', which we get when importing GCSToLocalFilesystemOperator. Not sure why Airflow took providers out of the base install, this is very frustrating...
The answer to my original question was that I needed to rebuild the docker image (DOH).
The answer to my second question, I think, was that I was installing these packages twice (once with an explicit pip install in the Dockerfile, and once in the requirements.txt, which is also pip installed in the Dockerfile). When I removed the duplicate install, it seems to be working now.

Fatal error while installing keras

I was trying to install keras (for using LSTM) on my Windows 10 system in Anaconda using the method provided by Yelaman. But after running the command pip install git+git://github.com/Theano/Theano.git, I received the following fatal error -
C:\Anaconda>pip install git+git://github.com/Theano/Theano.git
Collecting git+git://github.com/Theano/Theano.git
Cloning git://github.com/Theano/Theano.git to
c:\users\krishna\appdata\local\temp\pip-reettr-build fatal: protocol
error: bad line length character:
Er
Command "git clone -q git://github.com/Theano/Theano.git
c:\users\krishna\appdata\local\temp\pip-reettr-build" failed with
error code 128 in None
I don't have a github account but i use git using bitbucket (if that matters).
Could anyone explain to me what error I am committing and if there is a way out? My main goal is to use keras in Anaconda in Windows.
Thanks!
It seems that the error may be because we have a git repository listed as a dependency. Not still fully sure, though. (Source)
The solution is to replace pip install git+git://github.com/Theano/Theano.git with pip install git+http://github.com/Theano/Theano.git i.e. replacing the second git with http (this works since the repository is public)

Heroku - Flask - Bcrypt error

I am attempting to deploy a flask app on Heroku and it always errors at the same place. GCC fails to install and compile the Bcrypt module so I removed it from my requirements.txt (it is not used in the app). When I view the requrements.txt file, there is no mention of Bcrypt but when I push to heroku, it still tries to install it. I have committed the most recent version of requirements.txt to Git. Any help would be greatly appreciated.
I was able to solve this by using this custom heroku build pack:
heroku config:add BUILDPACK_URL=git://github.com/mfenniak/heroku-buildpack-python-libffi.git
I was able to get around it kind of, by successfully installing the following: "Successfully installed z3c.bcrypt python-bcrypt py-bcrypt-w32". Installing one of these (likely the second one) is what probably included the main bcrypt library that I guess needed to be compiled? I not 100% sure... I noticed this post is from July, I was able to download those libraries all using PIP.
Add cffi or cryptography in requirements.txt .That solved the problem in my case.

Categories