How i can run a python file - python

Please, can someone provide me with the way to run this project in Python?
https://github.com/Spidy20/Smart_Resume_Analyser_App.git
I tried run it with Pycharm and vs

pip install -r requirements.txt
streamlit run App.py
more info in README.md
https://github.com/Spidy20/Smart_Resume_Analyser_App/blob/master/README.md

Related

uwsgi.ini failed: No such file or directory when running Docker container

I have the following Dockerfile for my Dash app:
# syntax=docker/dockerfile:1
FROM python:3.8 AS build
RUN pip install --upgrade pip
COPY requirements.txt /srv/build/requirements.txt
RUN pip install --requirement /srv/build/requirements.txt
COPY . /srv/app
WORKDIR /srv
CMD ["uwsgi", "--ini", "uwsgi.ini"]
Which is being built as follows:
docker build -t dashboard .
And ran as follows:
docker run dashboard
The issue is that when I run it, I am encountering the following error:
realpath() of uwsgi.ini failed: No such file or directory [core/utils.c line 3662]
I have been attempting to unpack this more but still struggling. I tried switching around the directory structure of my project and adding uwsgi to the requirements.txt file which I saw recommended in other places. Unfortunately, that didn't fix the issue.
Any suggestions as to what I am doing wrong here?

Pip Installs not working through DockerFile

I'm new to Docker and Python, and I think I messed something terribly up while jumping between tutorials.
I am trying to get a python app to run in Docker. Python app uses Flask (I was following this guy's tutorial - https://www.youtube.com/watch?v=4T5Gnrmzjak)
The main problem is, I get the 'No module named 'flask''.
Dockerfile.txt is as so:
FROM python:3
WORKDIR /usr/src/app
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
CMD [ "python", "./test.py" ]
My requirements.txt:
Flask==1.1.2
Test.py:
from flask import Flask
print ('Hello')
I run "docker-compose up" and it gives me the "ModuleNotFoundError: No module named 'flask'"
Running the test.py works fine without Docker in the picture.
The pip install requirements.txt also works fine without Docker in the picture.
Anyone know what's going on?
Thank you in advance! ^^

ERROR: Directory is not installable. Neither 'setup.py' nor 'pyproject.toml'

I've got the following error:
ERROR: Directory is not installable. Neither 'setup.py' nor 'pyproject.toml'
Background is that I'm following a guide online to expose an ML model via API Gateway on AWS that can be found here:
Hosting your ML model on AWS Lambdas + API Gateway
I'm trying to pull some python packages into a local folder using the following command:
pip install -r requirements.txt --no-deps --target python/lib/python3.6/site-packages/
I have also tried this:
pip install -r requirements.txt --no-deps -t python/lib/python3.6/site-packages/
and all I get is the above error.
Google is pretty bare when it comes to help with this issue, any ideas?
thanks,
Does this work?
You can create a new folder e.g. lib, and run this command:
pip3 install <your_python_module_name> -t lib/
Would suggest making the path explicit to requirements.txt, e.g. ./requirements.txt if you're running the command in the same directory
Also may need to add a basic setup.py to the folder where you're trying to install. The pip docs mention that this will happen if there's no setup.py file:
When looking at the items to be installed, pip checks what type of
item each is, in the following order:
Project or archive URL.
Local directory (which must contain a
setup.py, or pip will report an error).
Local file (a sdist or wheel
format archive, following the naming conventions for those formats).
A
requirement, as specified in PEP 440.
https://pip.pypa.io/en/stable/cli/pip_install/#argument-handling
Please try this:
ADD requirements.txt ./
pip install -r requirements.txt --no-deps -t python/lib/python3.6/site-packages/
syntax: ADD source destination
'ADD requirements.txt ./' adds requirements.txt (assumed to be at the cwd) to the docker image's './' folder.
Thus creating a layer from which the daemon has the context to the location of requirements.txt in the docker image.
More about it in dockerfile-best-practices
you can change your directory as follow
import os
os.chdir(path)
instead of:
cd path
also try to use:
!pip freeze > requirements.txt
instead of:
pip install -r requirements.txt
then execute your code:
!pip install .
or
!pip install -e .
in conclusion try this:
import os
os.chdir(path)
!pip freeze > requirements.txt
!pip install .

Containerising Python command line application

I have created a Python command line application that is available through PyPi / pip install.
The application has native dependencies.
To make the installation less painful for Windows users I would like to create a Dockerised version out of this command line application.
What are the steps to convert setup.py with an entry point and requirements.txt to a command line application easily? Are there any tooling around this, or should I just write Dockerfile by hand?
Well, You have to create a Dockerfile and build an image off of it. There are best practices regarding the docker image creation that you need to apply. There are also language specific best practices.
Just to give you some ideas about the process:
FROM python:3.7.1-alpine3.8 #base image
ADD . /myapp # add project files
WORKDIR /myapp
RUN apk add dep1 dep2 #put your dependency packages here
RUN pip-3.7 install -r requirements.txt #install pip packages
RUN pip-3.7 install .
CMD myapp -h
Now build image and push it to some public registry:
sudo docker build -t <yourusername>/myapp:0.1 .
users can just pull image and use it:
sudo docker run -it myapp:0.1 myapp.py <switches/arguments>

Heroku: Run a Rails application with a Python script on the same instance

I have a Python script in the /app/bin directory of my Rails app that contains a requirements.txt file that includes all of the dependencies it relies on.
How do I get it to run on the same Heroku instance that my Rails app currently runs on (my Rails app call the python script occasionally).
Here's what I've tried so far:
Put the requirements.txt file in the / dir. Didn't install any python dependencies
Tried running heroku run bash and then running pip install -r requirements.txt. Got the message pip command not found.
Tried installing pip through the bash interface using sudo python get-pip.py after curling the script as suggested on the pip installation site. Didn't work -- not surprisingly, they don't support sudo commands on the instance.
I know Heroku is supposed to support pip out of the box, but it doesn't seem to do anything with the requirements.txt file once it's detected a Ruby app.
You can use the Heroku Buildpack Multi to run both the python and the ruby application on the same instance using their respective buildpacks.
keep requirements.txt file in project folder. In my case project name is stock09. so requirements.txt file in side of stock09
heroku login
heroku buildpacks:set heroku/ruby
heroku buildpacks.set heroku/python
heroku buildpacks
git add .
git commit -m " "
git push heroku master
now it work

Categories

Resources