Creating a Python Virtual Environment Using virtualenv

There are loads of tutorials out there for getting started with Python, but all of the ones I’ve come across miss some critical information. It’s often that the writer makes unfounded assumptions and beginners are left to piece and hobble together scraps from across the web to accomplish a simple task.

In the following, I’ll give you some basics about creating a Python virtual environment. I really do mean basics, things that I’m not going to assume you know about this process. Use this as a reference when you want to revisit how to start a new project or you blank on a terminal command.

By the way, I am working on a Mac, so your commands may look slightly different on other OS.

What you will need:

  1. A code editor. I use Sublime.
  2. Basic knowledge of your terminal.
  3. Python installed. If you have a Mac, you already have a version of Python installed.

If you want to check for Python on your computer, use the following command: python -V

My output for this command was: Python 2.7.16

What’s a virtual environment?

A virtual environment is a place for you to install packages that are specific to your project. Packages give your code special abilities. For example, I built a Slack bot called Nice Vegan Bot. You can type @niceveganbot and “fact please” in any Slack channel and you will be returned a fact about veganism from my MySQL database. For this bot, I used the package slackClient, which allowed me to feed my application with my Slack API token.

I came from a background in JavaScript where I installed packages using npm (and yarn a few times). When you’re working with Python, it’s highly suggested that you use a virtual environment for your project rather than install packages globally to your machine. A virtual environment simply keeps your dependencies isolated to your specific project. Get in the practice of using a virtual environment for all of your Python projects and you will alleviate the risk of package conflicts on your machine.

How to create a virtual environment.

Let’s make a new Python project and add a virtual environment.

In the following instructions, you will be asked to run commands that start with pip. pip is the package installer for Python. You already have pip if you have Python, so go ahead and run those commands.

Install virtualenv, a popular virtual environment package. Skip this step if you already have virtualenv installed. This command installs virtualenv globally so that you can add it to as many Python projects as you’d like.

pip install virtualenv

For reference, you can run this command to check which pip packages you have installed globally: pip list

CD into your Python project.

cd sample-application

Create a virtual environment specific to this project. The second part of the command below is anything we want to name the environment. So in this case, I called it ENV.

virtualenv ENV

Now we need to activate our new environment, ENV. Run the following command. If you named your environment anything other than ENV, replace ENV with the name of your environment.

source ENV/bin/activate

Now you’ll know that your environment is running when it appears in your project command line. You’ll see that the environment is listed in parentheses.

(ENV) Falons-MacBook-Pro:sample-application falondarville$

At this point, you can go ahead and install the packages you need for this specific project. The Python Package Index is your go-to reference for pip packages available.

Finally, to stop your environment, run deactivate

Now you know how to add a virtual environment to your Python project to keep your dependencies separate and potentially avoid package conflicts.


The Future of Work

I often speak to people about some things that they find startling. That’s my vision of the future of work. I’m going to share those ideas here. They are not popular, because they are not in sync with what is and what we have been taught to think about concepts like laziness, exertion, and effort. First I’ll go over some of the ideas that we currently have about work and why they are toxic and must be fazed out of our society. See also my blog post on my thoughts about how companies need us to have needs.

Working 40 hours a week.

Why 40 hours? Why not 36, or 42, or 20? Where did this number come from? It is absolutely arbitrary. Yet, it traverses the allotted work schedules of people across tremendously variant fields and positions. It is nonsensical to work for a specific amount of time each week. If you have worked on your own projects or in collaboration, you know that your work load varies week per week, even if you are performing the same tasks. What ends up happening for a lot of office workers that I have spoken to is that a lot of the time, we end up having to come up with creative ways to pretend to be working. That’s exhausting.

Beyond having to come up with ways to appear like we’re working, humans don’t have the stamina to work in sets of 8 hour intervals. Sure, we may take breaks. But when we are on the clock, we are supposed to be on. It’s not reasonable to expect humans to perform consistently for 8 hours 5 days a week. From my experience with the creative process and working as a freelancer, I enter waves of extreme concentration. This may last a couple of hours. Then I have to walk away from my desk and do a more tactical task like cleaning or walking outside. There’s also an unspoken rule in offices that you’re lazy or odd if you take breaks. Anyone working in an office has felt the icy judgment of management (and even coworkers) upon taking a short break to see the sunlight.

Further, there are many weeks where I work more than 40 hours because I don’t feel that there is enough mental stimulation at my work to keep me satisfied. So I engage in freelance gigs to work my brain more rigorously. The amount of hours of work we do per week has no bearing on satisfaction, only the work that we do. We should be free to work the hours that we need to “get the job done” and then focus on different activities that are self-enriching. Can you imagine a workplace that trusted employees to do their best, and work only the hours that they need in order to complete the tasks assigned?

Work-life balance.

Most people talking about work-life balance on LinkedIn are full of shit. For example, I read a post last week written by a manager. She said that her new employee was terrified that she would be mad at her for getting a flat tire and being late to work as a result. The boss said that she reassured the employee that there was a work-life balance at the new company, and that the employee should not be afraid. That’s not work-life balance. We are still very childish when it comes to understanding work-life balance. It’s not whether or not someone should be able to respond to life occurrences like a flat tire. That’s ridiculous.

Work-life balance still does not address the extent of humanness, which encompasses individuals dealing with mental health, their personal lives, illness, and more. Work places do not allow room for simple human needs like an extra hour on lunch on a difficult day for the employee to be able to go to a park and meditate. We don’t see humans as humans in the work place. Employees are still treated like they are producers. The rampant incline of mental health talk should be bringing about quicker change in this arena. But we are still stuck in Ford’s time. Efficiency at all costs. And we call work-life balance not being pissed when someone gets a flat tire. We call work-life balance letting someone go to the doctor. We call work-life balance allowing someone to go home when they are sick.

Hierarchical structure.

We need to do away with hierarchal structure in the workplace. When we treat people in the manner of a caste system, then they will reflect those roles back to us. For example, if I go into work each day and am treated as if I am an imbecile, I will act accordingly, because that is the manner in which I will be seen. There is no amount that I can “prove myself” to shift the views of people adamant about viewing me in a particular light. If, instead, we viewed people in their strengths and their light, we would see that they act much more in favor of the company.

After all, it’s called a company for a reason. We take company with a group of people and tackle a common goal. When we have implementations of a hierarchal structure, then we are no longer a company, but a caste system that operates out of fear and illusion. The illusion is that some people in this world hold more importance than others. We all hold importance in our own strengths (and weaknesses!). Society has conditioned us to see the world in roles. We are conditioned to aspire to these roles, and others are set as gatekeepers. There is no hierarchy in the natural world, only the wains of cycles. We can feign to hold caste systems in the workplace, but those are fabrications meant to stroke egos.

The future of work.

These are the projections that I have about the future of work. Those who say that they are unreasonable are the same that thrive on the hierarchy and lack of change. They may not recognize that there is a lot of work to do outside of a standard job. We are entering an era of increasing flux and change, especially with the speed at which technology and interpersonal relationships are driving us.

  1. We will work towards the achievement of tasks and goals, regardless of hours spent.
  2. We will accommodate for mental health and real life outside of traditional work.
  3. We will work as collaborators, not in a caste system.

I see these changes happening in the realm of self-employment especially. We have tremendously talented and forward-thinking individuals who are taking their futures into their own hands. They are turning their backs on cubicles, office gossip, and inflated egos. They are buckling down and creating themselves. They are pushing the boundaries that we put on ourselves through society’s teachings. There is no more room for us to make ourselves crazy working in a very specific and very toxic way. We must expand consciousness to allow for humanness to enter work.


Habits of Empowerment

You don’t have to be in a position of power to feel empowerment. Often, it will be in those states of feeling like your time is not your own (or that you have no control over what you put out into the world) that you have the awesome opportunity to develop habits that make you feel empowered. My generation is made up of complete trailblazers who don’t stand to be limited because of their circumstances, their net worth, and their experience. Even if we don’t have much materially speaking, we are a group that will voice our needs and work to make a life that works better for our personalities, temperaments, and creative aspirations.

I often come to an end-of-the-week slump where I feel completely immobilized by tethering to my current workplace. It is a feeling that I am not using all of my skills, and that there is so much more I could be pulling out of myself and displaying. There could be a number of variables at play, which I will not go into in detail. But the takeaway is that I end the week feeling out of my power. I spend the weekend reclaim my identity, just to go back into the workweek and feel my power fluttering away again.

Even when we are not in optimal positions that suit us, we can develop habits of empowerment. These habits can keep us from feeling like our future is not completely in the hands of others. The following are the things that I do to reclaim my power and charge up for the upcoming workweek.

I acknowledge that I have room for my work at home.

I look at the space that I have cultivated in my apartment and in my personal life to play with other work that I do like writing for this blog, freelancing, and taking a ceramics class. I thank myself for giving myself the room to grow and I repeat to myself that the things I do at home will also help me to feel more satisfied at work.

I seek alternative opinions and work on my mind.

Every time I feel claustrophobic in my own life, I head to the bookstore. These tremendous places of knowledge open me back up and it’s inevitable that I walk out with a couple books and a smile on my face. Work is not the end of your mental stimulation. If you are like me, you absolutely crave learning new things and you’re always looking for new avenues of thought. I feel incredibly empowered when I learning new things, and even more so when I discover a new topic of interest.

I learn more about myself and dig into my feelings.

When I feel as though the outside world is not offering the attention, praise, or other egoic things I’d like, I dig deeper into myself. I do this by journaling and thinking. I ask myself why I put importance of specific segments of my life. I look at societal conditioning. I think about learned patterns. I dig into perception. I find comfort in understanding my own thought process and empowerment in my ability to be malleable.

Empowerment, like all things, comes from the self. The ego will convince you that you need something outside of yourself to acknowledge your worth. The ego will trick you into measuring yourself up to anyone other than yourself. Empowerment will set your ego down and explain to it very rationally that it doesn’t stand a chance. And when your ego tries to fight back with a booming voice and tears of rage, your inner power will soothe the wounded parts of yourself and set the ego back in its place.