Python with virtualenv

in dev •  7 years ago  (edited)


@themarkymark made a good tutorial on setting up Steem-Python for Windows.
He only forgot to mention one little thing:

Virtualenv

What is it

Imagine, you have multiple python apps on your server. Some need version 1 of library FooBar, some need version 2 of it.
How could you install 2 different versions of one library on the same machine?
Or another scenario, you don't want to install it as root.
You are just a normal user, without root/admin privileges and need to install that library.
Virtualenv steps in here.
You basically create a new path for your application, where python and all libraries will be installed.

How to install it

This section covers Python Version 3.3+.
Go into your directory, where your application will be.
On Linux enter:
python3 -m venv ENV_DIR
On Windows enter:
C:\Python36\python.exe -m venv ENV_DIR

python3 and C:\Python36\python.exe are your Python executables. This differs from Python version to Python version.

ENV_DIR is a non existing folder, that will be created, I usually use env as name, but this is up to you.

How to use it

Go to your application folder.
On Linux:
$ source env/bin/activate
On Windows:
$ env\Scripts\activate
And your command line will now look like that:
(env)$

Now you can pip install all the things you want.
Oh, and you exit this environment like that:
(env)$ deactivate

You want to get rid of that environment?
$ rm -rf env
On Windows, you just delete the env folder

If you like that tutorial, you can vote for me as witness!

Did you know, that you can make some profit with your witness vote?

Also sorry for the blatant image copy;)

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

This post has been upvoted by @minibot with 30.0%!
Thank you for giving your trust and witness vote to my creator @isnochys!

This post has been upvoted by @microbot with 25.9%!
Thank you for giving your trust and witness vote to my creator @isnochys!