G

Gunderson blog

Husband, Father & Friend Electrical/Software Engineer & Musician

Using Virtual Environment & Requirements.txt with python

Virtual Environment Summary

Virtual Environment makes it easy to make an easily reproducably deployable environment. It keeps the environment separate from the rest of the system, thus also making uninstalling requirements much easier.

Steps

  • General Install
  • Setup
  • Activate
  • (Deactivate)

Install & Setup

If you're using python 3.4+, you can use the built-in "venv" as shown below:
python3 -m venv [my-venv-directory]

Otherwise, install the "virtualenv" package

  • install: pip install virtualenv

  • make env directory: virtualenv [my-venv-directory]

Linux Specific Commands

  1. Activate: source [my-venv-directory]/bin/activate

  2. Deactivate: deactivate

Windows Specific Commands

  1. Activate: [my-venv-directory]\Scripts\activate.bat

  2. Deactivate: [my-venv-directory]\Scripts\deactivate.bat

Deleting an environment

First deactivate the environment, then just delete the directory

Using python scripting

the following code should make a python script use the virutal environment

env_dir = os.path.abspath(env_dir)
context = self.ensure_directories(env_dir)
self.create_configuration(context)
self.setup_python(context)
self.setup_scripts(context)
self.post_setup(context)

Requirements.txt

Make a requirements file

pip freeze > requirements.txt

Using requirements.txt

pip install -r requirements.txt

References

https://python.land/virtual-environments/virtualenv
https://docs.python.org/3/library/venv.html#venv-def
https://pip.pypa.io/en/stable/user_guide/#requirements-files

Initial Review of Listed.to

First day with listed.to
so far I'm really impressed with the ease of getting setup with blogging right from my notes. Really great idea and it makes me excited.. despite not actually knowing what I'd want to blog about.

Looking around at some of the other blogs, I didnt see many others trying out the custom css option. So I've made an effort to try it out.

Here are the main things worth mentioning:

  • Extremely glad they had example css to get started, especially listing some of the predefined color variables

  • Unfortunately, some of the variables didnt seem to apply to anything, while other very necessary variables either didnt work or were atleast not listed

  • Testing the updates as I worked was easy. just upload changes and perform a hard refresh on the browser

One kinda awkward resulting issue with uploading custom css is the settings page for you blog takes on some of those changes.. and well sometimes that makes it really hard to read if you weren't expecting to effect that as well. I had to go back and make some changes so I could see the text on the settings page.

First Blog

Testing 1,2,3

Trying out my first blog post.

First order of business is to get some css looking pretty.

Using the following instructions:
listed.to css instructions

And making a bunch of modifications!