You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 3c99b32
Browse filesBrowse the repository at this point in the historyBrowse files
The use of a Virtual Environment is to test python code in encapsulated environments and to also avoid filling the base Python installation with libraries we might use for only one project.
3993
-
3994
-
[*Return to the Top*](#python-cheatsheet)
3995
-
3996
-
### Windows
3997
-
3998
-
1. Install virtualenv:
3999
-
4000
-
pip install virtualenv
4001
-
4002
-
1. Install virtualenvwrapper-win:
4003
-
4004
-
pip install virtualenvwrapper-win
4005
-
4006
-
Usage:
4007
-
4008
-
1. Make a Virtual Environemt:
4009
-
4010
-
mkvirtualenv HelloWold
4011
-
4012
-
Anything we install now will be specific to this project. And available to the projects we connect to this environment.
4013
-
4014
-
1. Set Project Directory:
4015
-
4016
-
To bind our virtualenv with our current working directory we simply enter:
4017
-
4018
-
setprojectdir .
4019
-
4020
-
1. Deactivate:
4021
-
4022
-
To move onto something elsein the command line type ‘deactivate’ to deactivate your environment.
4023
-
4024
-
deactivate
4025
-
4026
-
Notice how the parenthesis disappear.
4027
-
4028
-
1. Workon:
4029
-
4030
-
Open up the command prompt andtype ‘workon HelloWold’ to activate the environment and move into your root project folder:
4031
-
4032
-
workon HelloWold
4033
-
4034
-
[*Return to the Top*](#python-cheatsheet)
4035
-
4036
3991
## Lambda Functions
4037
3992
4038
3993
This function:
@@ -4116,3 +4071,82 @@ else:
4116
4071
```
4117
4072
4118
4073
[*Return to the Top*](#python-cheatsheet)
4074
+
4075
+
## Virtual Environment
4076
+
4077
+
The use of a Virtual Environment is to test python code in encapsulated environments and to also avoid filling the base Python installation with libraries we might use for only one project.
4078
+
4079
+
[*Return to the Top*](#python-cheatsheet)
4080
+
4081
+
### virtualenv
4082
+
4083
+
1. Install virtualenv
4084
+
4085
+
pip install virtualenv
4086
+
4087
+
1. Install virtualenvwrapper-win (Windows)
4088
+
4089
+
pip install virtualenvwrapper-win
4090
+
4091
+
Usage:
4092
+
4093
+
1. Make a Virtual Environment
4094
+
4095
+
mkvirtualenv HelloWold
4096
+
4097
+
Anything we install now will be specific to this project. And available to the projects we connect to this environment.
4098
+
4099
+
1. Set Project Directory
4100
+
4101
+
To bind our virtualenv with our current working directory we simply enter:
4102
+
4103
+
setprojectdir .
4104
+
4105
+
1. Deactivate
4106
+
4107
+
To move onto something elsein the command line type ‘deactivate’ to deactivate your environment.
4108
+
4109
+
deactivate
4110
+
4111
+
Notice how the parenthesis disappear.
4112
+
4113
+
1. Workon
4114
+
4115
+
Open up the command prompt andtype ‘workon HelloWold’ to activate the environment and move into your root project folder
4116
+
4117
+
workon HelloWold
4118
+
4119
+
[*Return to the Top*](#python-cheatsheet)
4120
+
4121
+
### pipenv
4122
+
4123
+
> Pipenv — the officially recommended Python packaging tool from Python.org, free (asin freedom).
4124
+
4125
+
1. Install pipenv
4126
+
4127
+
pip install pipenv
4128
+
4129
+
1. Enter your Project directory and install the Packages for your project
4130
+
4131
+
cd my_project
4132
+
pipenv install <package>
4133
+
4134
+
Anything we install now will be specific to this project.
4135
+
4136
+
Pipenv will install your package and create a Pipfile for you in your project’s directory. The Pipfile is used to track which dependencies your project needs in case you need to re-install them.
4137
+
4138
+
1. Uninstall Packages
4139
+
4140
+
pipenv uninstall <package>
4141
+
4142
+
1. Activate the Virtual Environment associated with your Python project
4143
+
4144
+
pipenv shell
4145
+
4146
+
1. Exit the Virtual Environment
4147
+
4148
+
exit
4149
+
4150
+
Find more information and a video in [docs.pipenv.org](https://docs.pipenv.org/).
0 commit comments