Installing requirements.txt on heroku runs error - python

I am deploying an application using heroku. In the python code I am using a NLP library called spacy.
I already deployed the app without any installed library, working perfectly.
I added the library in the requirements.txt of the app:
In my cmd, at the time of deployment I am using:
pip install -r requirements.txt
However, it runs an error:
intentionally avoided writing the code because of the sizeI also installed Microsoft C++ Build Tools and restarted cmd, but now it runs additional errors.
This is a screenshot of the files I am uploading:
Is there a way I can install the libraries remotely? I would like to avoid countless installations. Given the red code, am I doing something wrong or am I just missing packages?
(intentionally avoided writing the code because of the size)

That is a local error on your Windows machine, that should not occur on Heroku. The Heroku build pack should automatically install dependencies if you put requirements.txt at root. See https://devcenter.heroku.com/articles/python-pip
For fixing your local error, you need to install the C++ build tools as per the error message.

Related

Why are my Python packages being installed to this strange folder?

I am encountering issues with installing certain Python modules on Windows, using pip. In particular, I am using Flask, but I am encountering the error 'flask' is not recognized as an internal or external command,
operable program or batch file. in command line.
However, I am able to run my code properly with python -m flask run for some reason. After investigating, I figured there was a problem with my installation of Flask, so I did pip install --upgrade --force-reinstall flask to hopefully fix the issue. I then encounter the warning message: the script flask.exe is installed in 'C:\Users\Name\Appdata\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\Scripts' which is not on PATH.
Why would my package be installed to this location? My understanding is the default location for a package installation should be C:\Users\Name\AppData\Local\Programs\Python\Python38\Lib instead. How can I fix this. It seems all my packages are being installed to this strange folder, which is giving me countless issues. I have tried force upgrading pip, and reinstalling python to no avail.

aws sam build not able to build packages which require paramiko due to "Error: PythonPipBuilder:ResolveDependencies"

I've been learning the ropes with AWS SAM and have successfully deployed a number of lambdas together with dependencies and other AWS services. However, I seem to have run into a problem when trying to deploy a lambda which relies on some specific dependencies.
Here is my requirements.txt file:
paramiko==2.4.2
cryptography==2.6.1
bcrypt==3.1.6
pynacl==1.3.0
This file is found in "packageRoot/myCodeUri/requirements.txt"
When I run sam build I get the following error:
2019-08-27 11:18:18 Running PythonPipBuilder:ResolveDependencies
Build Failed
Error: PythonPipBuilder:ResolveDependencies - {pynacl==1.3.0(wheel), cryptography==2.6.1(wheel), bcrypt==3.1.6(wheel)}
This (or at least similar) errors have been reported:here over 8 months ago but is currently not answered.
P.S. I tried this originally with just paramiko as this is the only library my script uses, as I understood; the dependencies should be automatically pulled in during the build, however this didn't work either.
Any help would be great?
I was getting same error with another dependency while running sam build. I was able to resolve this by installing wheel in our python (or venv) environment.
pip install wheel
This approach did not require --use-container flag while running sam build
Installing wheel didn't work for me, however upgrading pip did.
python -m pip install --upgrade pip
I've managed to get a workaround to build and deploy lambdas that need the paramiko library using a docker container in interactive mode. Anyone having the same problem have a look here
I had this issue when trying to use simplejson library. It was added to solve serialization issues... (pip wheel and upgrade didn't help), I just deleted the library and handle the serialization issues within the db query)

Installing dlib on heroku

I've had trouble installing dlib, specifically the python verson, on my heroku app. I compiled everything fine on my local machine but when I push dlib.so and the build directory to heroku, whenever I try importing I get ImportError: libboost_python-py27.so.1.54.0: cannot open shared object file: No such file or directory. I made sure that dlib.so is in my LD_LIBRARY_PATH. What am I missing?
Dlib requires boost which can be hard to install successfully, as you have discovered.
The rule of thumb is to use Heroku Buildpacks to install such libraries.
To install Dlib, go to your Heroku dashboard, settings and click on Add Buildpack.
Depending on your python version you can use any of the two Buildpacks below;
For python 2.7.13
https://github.com/J-A-M-E-5/heroku14-buildpack-python-opencv-dlib.git
For python 3.6.1
https://github.com/J-A-M-E-5/heroku16-buildpack-python-opencv-dlib.git

Django Error: cannot import name autodiscover_modules

I meet this error when I deploy my Django project on another VPS. The same codes can run successfully on my Macbook and a staging VPS.
My website based on Django 1.4.20, and import some third python library and Django apps, for example redis-py, requests, django-import-export, django-kronos, django-cors-headers. I install these by pip install etc
I'm really confused how these happen. Maybe it's a library dependency problem, but I can't find detail error log or stacks. Thanks for your time.
You should have a requirements.txt with your webapp. Then do pip install -r requirements.txt when you deploy.
If you did not make such a file, you can create one later by running pip freeze > requirements.txt. But beware that there might be some packages there that are not needed, if you installed other stuff on the side, so be prepared to manually screen the file.
If you work with multiple webapps you may also need to containerize your requirements (here's why). Two options: Docker or virtualenv. If you don't know what Docker is and don't have some time on your hands I suggest you go with Virtualenv for now.

Errors installing mysql-python on Azure

Unsure if I should be using Server Overflow or not... Using Django websites on Azure, deploying via GitHub... I have mysql-python in the requirements.txt and even went as far to add the site-packages to my application root... Getting the following error.
error: Microsoft Visual C++ 9.0 is required (Unable to find vcvarsall.bat). Get it from http://aka.ms/vcpython27
I have been able to use the mysql-python binary install (http://www.lfd.uci.edu/~gohlke/pythonlibs/). After running pip install on the mysql .whl file I then copy everything starting with MySQLdb in the name from my default python install (C:\Python27) for me, to the virtualenv that I am using for my project. I hope this might help.

Categories

Resources