• Home
  • Releases
  • Submit Vuln
  • Press
  • About
  • PGP
  • Contact
    • Contact
    • Submit Vuln
    • VDP
  • Tutorials
    • All Posts
    • Photoshop on Linux
    • macOS on Linux
  • Supporters
  • Projects
  • Training
Sick Codes - Security Research, Hardware & Software Hacking, Consulting, Linux, IoT, Cloud, Embedded, Arch, Tweaks & Tips!
  • Home
  • Releases
  • Submit Vuln
  • Press
  • About
  • PGP
  • Contact
    • Contact
    • Submit Vuln
    • VDP
  • Tutorials
    • All Posts
    • Photoshop on Linux
    • macOS on Linux
  • Supporters
  • Projects
  • Training
No Result
View All Result
Sick Codes - Security Research, Hardware & Software Hacking, Consulting, Linux, IoT, Cloud, Embedded, Arch, Tweaks & Tips!
  • Home
  • Releases
  • Submit Vuln
  • Press
  • About
  • PGP
  • Contact
    • Contact
    • Submit Vuln
    • VDP
  • Tutorials
    • All Posts
    • Photoshop on Linux
    • macOS on Linux
  • Supporters
  • Projects
  • Training
No Result
View All Result
Sick Codes - Security Research, Hardware & Software Hacking, Consulting, Linux, IoT, Cloud, Embedded, Arch, Tweaks & Tips!
No Result
View All Result
Home Tutorials

PIPENV Crontab & Docker: How to Run PIPENV Python Automatically Properly in Cron Jobs with Pipenv – Running Django On a Server

by Sick Codes
May 8, 2020 - Updated on June 24, 2020
in Tutorials
0
how to run pipenv inside a docker container

how to run pipenv inside a docker container

How to run Pipenv in a Docker Container, or using Crontab

When you run pipenv shell, you will notice a link in you console terminal output with a dot (.) symbol.
This symbol is the shell command for “source”.

pipenv cron job source activate
pipenv cron job source activate

If you haven’t installed pipenv here is the setup:

# Install Pipenv on Ubuntu / Debian (Works on Docker)
apt install pipenv -y
pip3 install --upgrade pip
pip3 install --upgrade pipenv
touch Pipfile
export SHELL=/bin/bash
python3 -m pipenv --python 3.8

# CentOS / Red Hat
yum install epel-release
yum install python3 python3-pip
pip3 install pipenv
touch Pipfile
pipenv install

Locate your activate bin file:

find $HOME/.local/share/virtualenvs/ | grep 'activate$'

Now you can use that activate bin inside your cron jobs as follow:

# these two commands are the same
. /home/admin/.local/share/virtualenvs/private-3Qz0_VCC/bin/activate
# or
source /home/admin/.local/share/virtualenvs/private-3Qz0_VCC/bin/activate

This gets your inside your python pipenv shell, where running “python” does it’s magic.

For example, here’s how to run Django
Type “crontab -e” and enter the cron job

source /home/admin/.local/share/virtualenvs/private-3Qz0_VCC/bin/activate && cd /home/user/ && nohup python manage.py runserver 127.0.0.1:9988 &

Here are some examples to help you understand

Here’s a fully automated Docker way:

# in any ubuntu image

RUN apt update -y
RUN apt install pipenv -y
RUN pip3 install --upgrade pip
RUN pip3 install --upgrade pipenv
WORKDIR /opt
RUN export SHELL=/bin/bash
RUN python3 -m pipenv --python 3.8

If you receive this error:

  File "/usr/lib/python3/dist-packages/pipenv/project.py", line 475, in create_pipfile
    config_parser = ConfigOptionParser(name=self.name)
  File "/usr/lib/python3/dist-packages/pipenv/vendor/pip9/baseparser.py", line 149, in __init__
    assert self.name

AssertionError

you can try two things

export SHELL=/bin/bash
pipenv shell
touch pipfile
pipenv shell
Next Post
django forms field generator automatically after

Advanced Django Tricks: Dynamically & Automatically Generate Form Fields Using Python Local Variables

How to Add Private Networking in CentOS 8/Ubuntu on Vultr (One-liners/AUTO)

How to Install GlusterFS On CentOS 8

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

No Result
View All Result
  • Home
  • Releases
  • Submit Vuln
  • Press
  • About
  • PGP
  • Contact
    • Contact
    • Submit Vuln
    • VDP
  • Tutorials
    • All Posts
    • Photoshop on Linux
    • macOS on Linux
  • Supporters
  • Projects
  • Training

© 2017-2021 Sick.Codes

@sickcodes

@sickcodes

@sickcodes

Discord Server

sickcodes.slack.com

t.me/sickcodeschat

./contact_form