Skip to content

Commit 16de2e0

Browse files
committed
virtual setup
1 parent 98ce461 commit 16de2e0

File tree

2 files changed

+67
-1
lines changed

2 files changed

+67
-1
lines changed

Python_virtualenv_setup.md

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Python-Virtualenv-Setup
2+
3+
For setup virtual environment you must need python environment in your OS system.
4+
How to set up a Python development environment :
5+
==============================================
6+
7+
A Python development environment is a folder which you keep your code in, plus a "virtual environment" which lets you install
8+
additional library dependencies for that project without those polluting the rest of your desktop/laptop.
9+
10+
mkdir my-newproject
11+
cd my-newproject
12+
virtualenv --python=python3.7 venv
13+
# This will create a my-new-python-project/venv folder
14+
touch .gitignore
15+
subl .gitignore
16+
# Add venv to your .gitignore
17+
18+
Now any time you want to work on your project, you need to "activate your virtual environment". Do that like this:
19+
20+
cd my-newproject
21+
source venv/bin/activate
22+
23+
You can tell it is activated because your terminal prompt will now look like this:
24+
25+
(venv) computer:my-newproject user$
26+
27+
Note the (venv) bit at the start.
28+
29+
If you get an error like :
30+
31+
"source : The term 'source' is not recognized as the name of a cmdlet, function, script file, or operable program.
32+
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
33+
At line:1 char:1
34+
+ source venv/bin/activate
35+
+ ~~~~~~
36+
+ CategoryInfo : ObjectNotFound: (source:String) [], CommandNotFoundException
37+
+ FullyQualifiedErrorId : CommandNotFoundException"
38+
39+
then try this:
40+
#To install :
41+
pip install --user virtualenv
42+
#To create a virtual environment (venv):
43+
python -m virtualenv venv
44+
#To activate:
45+
-cd venv
46+
-cd Scripts
47+
-activate.bat
48+
#if you get an error on activate.bat then try
49+
.\activate.bat or activate
50+
#to deactivate:
51+
-deactivate.bat or deactivate
52+
#to run venv again just type activate.bat
53+
54+
55+
Once it is activated, any time you run the "python" or "pip" commands it will be running the special custom versions in your venv folder.
56+
57+
You could also run them without activating the virtual environment like this:
58+
59+
venv/bin/python
60+
venv/bin/pip
61+
62+
To install new python libraries, use pip like this:
63+
64+
pip install requests
65+
pip install ipython
66+
67+
It's always a good idea to install ipython.

README.md

-1
This file was deleted.

0 commit comments

Comments
 (0)