A real simple and quick VirtualEnv guide

Search for a command to run...

Resourceful, lot to gain. Nice blog AJ!
A quick cheatsheet for TMUX commands that I can never remember. tmux yum -y install tmux Out of tmux new session tmux new new session with name tmux new -s sessionname show sessions tmux ls attach to session tmux attach-session -t 0 Go to last sessi...
Here's a fun error: "not syncing vfs unable to mount root fs on unknown block" I'm running CentOS7 on Linode and happened to run into this error on one of my systems. Quite unusual, so I did the quick and dirty method and restored a backup of my VM....
I discovered a fun git command that I wasn't aware of before. git switch -c <new-branch> Using git switch, you can take existing, uncommitted files and move them to a new branch. Say you're working in the master branch and want to move those changes...
Well, maybe not so hidden, but definitely not advertised. Vudu has an API that, for the life of me, I could not find advertised anywhere, even with an advanced Google search. So, I'll take it upon myself to scrape their webpage and dissect their ho...
I didn't realize until recently that you can run DynamoDB on a local machine on either Windows, Mac, or Linux. This obviously can be hugely benefitial for learning and dabbling in DynamoDB, without racking up a large AWS bill. Let's see if we can get...
A real quick and simple note on creating Virtual Environments in Python.
You'll need Python3 installed, with Pip, and VirtualEnv installed.
First, install virtualenv using pip
pip3 install virtualenv
Then create a virtualenv at the path ~/venv/myvenv
#method 1
python3 -m venv ~/venv/myvenv
#method 2
virtualenv ~/venv/myvenv -p python3
Don't forget to activate
source ~/venv/myvenv/bin/activate
~/venv/myvenv/Scripts/activate.ps1
Of course, you'll validate that you're activated by the parenthesized env name
(myvenv) $ which python
/home/dir/venv/myvenv/bin/python
You can "shabang" your python scripts directly to this instance of python that includes your modules, that way your scripts always run with the correct version. Keep in mind the portability of your script though, as this path may change on other devices.
#!/home/dir/venv/myvenv/bin/python
Exit your venv with the command:
deactivate
Using pipenv can simplify the virtualenv process tremendously
You can install with your local package manager (apt, dnf, pkg, pip, brew)
pip install pipenv
brew install pipenv
Navigate to your development directory and run this to create a Python3 environment.
pipenv --three
The Pipfile manages what's needed for the project. Now use pipenv to install packages
pipenv install bs4
output
Installing bs4...
Adding bs4 to Pipfile's [packages]...
โ Installation Succeeded
Pipfile.lock not found, creating...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
Building requirements...
Resolving dependencies...
โ Success!
Updated Pipfile.lock (8cf921)!
Installing dependencies from Pipfile.lock (8cf921)...
๐ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ 0/0 โ 00:00:00
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
You can run your script with any of these commands
###straight python from the project dir
.venv/bin/python bs4test.py
###from the pipenv shell
pipenv shell
python bs4test.py
###with pipenv run
pipenv run python bs4test.py
I'm still learning the tricks of pipenv, so I'll have another writeup on the value of pipenv in the future.