why gunicorn command not found with gunicorn installed? - django

I have intalled gunicorn,but gunicorn command not found:
# pip3.4 install gunicorn
Requirement already satisfied (use --upgrade to upgrade): gunicorn in /usr/local/python3.4/lib/python3.4/site-packages
# gunicorn
-bash: gunicorn: command not found
what is the problem,is gunicorn install path not be recognized by system?

I faced the same issue and it turns out I had to add gunicorn binary path to Linux PATH variable. You can start by echoing $PATH to see all binary path listed on the system. Then find out where gunicorn is installed. For my case I was using python virtual environment and pyenv which helps manage several python versions and dependencies separately.
(venv3.6) dave#daverig (develop)✗ % pip show gunicorn
Name: gunicorn
Version: 19.7.1
Summary: WSGI HTTP Server for UNIX
Home-page: http://gunicorn.org
Author: Benoit Chesneau
Author-email: benoitc#e-engura.com
License: MIT
Location: /home/dave/.pyenv/versions/3.6.2/envs/venv3.6/lib/python3.6/site-packages
Notice gunicorn is installed in /home/dave/.pyenv/versions/3.6.2/envs/venv3.6/lib/python3.6/site-packages and the corresponding path for the binaries for this particular python version is at /home/dave/.pyenv/versions/3.6.2/envs/venv3.6/bin. So I had to add that to Linux path via ~/.profile file like so;
export PATH=$PATH:$HOME/.pyenv/versions/3.6.2/envs/venv3.6/bin then ofcourse you want to refresh this using source ~/.profile or restart your terminal. Once I was able to do this, gunicorn binary was now available on my console;
(venv3.6) dave#daverig (develop)✗ % gunicorn --version
gunicorn (version 19.7.1)

I had the same problem on Debian.
It turns out that on Debian the documentation advises to install gunicorn via apt:
$ sudo apt install gunicorn

i just created a file named gunicorn and type these codes below which is the same as my development server , and included it into system path,such as /usr/bin
#!/usr/local/bin/python3.4
#-*- coding: utf-8 -*-
import re
import sys
from gunicorn.app.wsgiapp import run
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$','',sys.argv[0])
sys.exit(run())
in this way, it solved my problem,but still confused me,why gunicorn command not generated and included into system path automatically?and why my development server did ,both the same OS (centos 6.5 x64)

Installing gunicorn from source saved me after 2 hours trying!
pip3 install git+https://github.com/benoitc/gunicorn.git

If you installed python3 from source compiled, you should export your python3 PATH:
export PATH=$PATH:/usr/local/python3/bin

Are you use python3.4-venv?
if true
Delete env folder
Just reinstall: python3.4-venv. Ex for ubuntu:
apt install python3.4-venv
Exec: python3.4 -m venv env
source env/bin/activate
reinstall gunicorn by : pip3 install gunicorn or install from requirements.txt by pip3 install -r requirements.txt

go to terminal and change directory to environment and then type the below command.
pip install gunicorn
#Enjoy1

Related

ModuleNotFoundError: No module named 'flask_sqlalchemy' error observer while i do running the docker images

I am getting ModuleNotFoundError No module named 'flask_sqlalchemy' when try to docker run of builded docker images.The same python flask run using terminal is working fine for me but not in docker?
FROM python:3.6
ADD . /app
WORKDIR /app
RUN pip install flask gunicorn
EXPOSE 8000
CMD ["gunicorn", "-b", "0.0.0.0:8000", "app"]
The good practice is to save file with installed pip packages, e.g. in requirements.txt. (preferably with only needed packages, e.g. when you are using pyevn).
This is done by pip freeze > requirements.txt (when located on local machine, in terminal).
Then, all you should do is replace RUN pip install flask gunicorn with RUN pip install -r requirements.txt and all installed packages on the local machine will be installed in the docker too.

App Engine: ImportError: No module named _gdal

How to enable python 2.7 library like GDAL in Google App Engine standard? Currently there are linux python-modules in lib-folder in app engine, but when trying to run the code through endpoints, app engine gives internal server error: ImportError: No module named _gdal. I'm using pygdal version 2.2.3.3. Should the libgdal (demanded for pygdal)be installed also on app engine, and if so, how to do it? I installed GDAL locally into lib folder (using ubuntu bash on windows10) following these instructions using this syntax: sudo pip install --target lib --requirement requirements.txt --ignore-installed as it says here. Please help!
From What compiler can I use to build GDAL/OGR?
GDAL/OGR is written in ANSI C and C++. It can be compiled with all modern C/C++ compilers.
Which means it's incompatible with the (1st generation/python 2.7) standard environment Pure Python sandbox requirement:
All code for the Python runtime environment must be pure Python, and
not include any C extensions or other code that must be compiled.
You may want to look at the flexible environment instead. Probably with a custom runtime, see Up-to-date pip with AppEngine Python flex env?
Google App Engine's standard environment for Python27 only supports a specific set of third-party libraries that use C-extensions, listed here. pygdal is not in the list.
You may want to look into the Python3 standard runtime, though it is in beta. It allows you to install arbitrary third-party libraries.
Modifying this links' answer I managed to get GDAL working in App Engine Flexible.
My dockerfile:
FROM gcr.io/google-appengine/python
RUN apt-get update && apt-get -y install libproj-dev libgdal-dev
RUN export CPLUS_INCLUDE_PATH=/usr/include/gdal
RUN export C_INCLUDE_PATH=/usr/include/gdal
RUN gdal-config --version
# Create a virtualenv for dependencies. This isolates these packages from
# system-level packages.
RUN virtualenv /env -p python2.7
# Setting these environment variables are the same as running
# source /env/bin/activate.
ENV VIRTUAL_ENV /env
ENV PATH /env/bin:$PATH
# Copy the application's requirements.txt and run pip to install all
# dependencies into the virtualenv.
ADD requirements.txt requirements.txt
RUN pip install -r requirements.txt
# Add the application source code.
ADD . /app
CMD gunicorn -t 120 -b :$PORT main:app
My app.yaml-file:
runtime: custom
env: flex
entrypoint: gunicorn -t 120 -b :$PORT main:app
endpoints_api_service:
name: xxxxx.com
rollout_strategy: managed
beta_settings:
cloud_sql_instances: project:europe-north1:dbinstance
runtime_config:
python_version: 2
requirements.text-file:
pygdal==1.11.3.3

how to install pip remotely using ssh

Hi I hope someone can point me in the right direction.
I am trying to upload a django project which I have developed locally on my machine and now moved the project files to a server and am trying to install django on the server.
I have Python 2.7.5 installed and accessed the server remotely using ssh (putty) I can confirm Python is installed by running the command python --version
I don't have pip installed as when i run the command pip --version
I get following notification
-bash: pip: command not found
I am new to django and python so not sure what I should do to install both django and pip.
p.s In my requirements file and when working locally I have pip and django installed correctly and all working.
Ok, lets say you are already on your remote server. First thing to do is to install pip for your version of python. You can do this via:
sudo apt-get install python-pip
From now you have pip installed. Next thing to do is to install django globally in your system:
pip install django==1.11
Please note that django 1.11 is the last version that supports
python2
Next thing to do is to create django app:
django-admin startproject test_project
And the last thing is to install virtualenv
To install libraries for each of your django projects and keep them
separate
pip install virtualenv
Also note
If you have requirements.txt file with all libs, you can do something like this on your remote server:
pip install -r requirements.txt
That will automatically install all libraries at once
First you should understand which OS you're running:
uname -a
and:
lsb_release -a
When you find the OS version, you can easily follow this guide:
https://packaging.python.org/guides/installing-using-linux-tools/#installing-pip-setuptools-wheel-with-linux-package-managers

Flask module cannot be found in pyvenv although it is installed

I used the following commands to create the virtual environment and run my code:
mkdir ~/.virtualenvs
pyvenv ~/.virtualenvs/bitirme
source ~/.virtualenvs/bitirme/bin/activate
pip3 install flask
pip3 install httpie
python3 server.py
Although flask is installed correctly I still get the error that flask module cannot be found. What am I doing wrong here?
Try to do this in the normal way (i guess, that you on *NIX):
Install "virtualenv" module via pip
Go to the directory, where you wanna create virtual environment
Type in terminal "virtualenv %name% %python_path%"
Now to activate, do "./%name%/bin/activate"
Install "pip install flask httpie"
Run "python server.py"
NOTE:
If you created virtual environment with your "python 3"
installation, you should not add "3" to python, or pip

What is the package name for python3 mod_wsgi on Centos 7?

I am looking for the python3 version of mod_wsgi for Centos 7.
I know that for fedora, it is python3-mod_wsgi and ubuntu is libapache2-mod-wsgi-py3. However, I am not able to find the equivalent for Centos 7. I need this package for my django website to run.
CentOS 7.3 does not have a package of mod_wsgi that is compiled against Python 3.
You can use pip to compile the module yourself:
sudo yum install httpd-devel gcc
pip install mod-wsgi
# Becoming root makes it easier to echo to a file in /etc/httpd
sudo -i
echo "LoadModule wsgi_module [path-to-your-virtual-environment]/lib/python3.4/site-packages/mod_wsgi/server/mod_wsgi-py34.cpython-34m.so" > /etc/httpd/conf.modules.d/00-wsgi.conf
exit
sudo systemctl restart httpd