Each project you work on should ideally have it's own environment.
Within Python, you can install software from the web and you can use modules and frameworks developed by other programmers.
Imaging this situation.
You're a programmer, working on two projects. Web App #1 and Web App #2
For Web App #1 you're using framework version #10 while for Web App #2 you're using framework version #8.
How would you work on both on the same machine?
/------------------/ /----------------/
| Web App # 1 | | Web App # 2 |
| | | |
| Framework # 10 | | Framework # 8 |
| | | |
| | | |
| | /----------------/
/------------------/
The answer to this is that you can use Python virtualenvironments to keep these projects separate and install different versions of your framework, one in each folder.
To start off, we need to get a little more familiar with the windows console

dir - lists contents of foldermkdir <Directory Name> - creates new foldercd <Directory Name> - enters a foldercd .. - enters a folder above the current oneWindows 10 makes it easy to get to a console. Just open your project folder, then click <Shift> + <Right Click> and select the option Open command window here.

Open up your console.
First, type python -V (lowercase) to make sure that you can access the Python command from your console.

You should see the current version of Python on your system.
If that works, you can proceed. The first command to execute is the one to create the virtual environment.
python -m venv env
When it finishes, you should have a new folder, env. This folder will hold any external libraries that you install.
To use the environment, you need to execute this command on Windows:
env\Scripts\activate.bat
or MacOS or Linux:
source env/bin/activate
Once you've done this, you're now in a Python virtual environment
In order to deactivate your virtual environment, run the command
Windows:
env\Scripts\deactivate
MacOS or Linux:
deactivate
Python has a tool for installing software from the web called "Pip." You invoke it from the console.
First, you need to open a console in your project folder, then activate your virtual environment.
Then, you run the pip command.
pip install requests
You should have copied the folder python-project to a directory on your machine as well as activated a virtual environment.
You'll have to run the following command after activating:
pip install -f windows-wheels -r requirements.txt
Or, use the provided scripts
install.batbash install.shThis will install all of the dependencies in your environment.
In order to make sure IDLE can see your installed libraries, you need to launch it from the console
env\Scripts\activate.bat
python -m idlelib
import webbrowser
webbrowser.open("http://sensi-sl.org")
True
import requests
res = requests.get("http://sensi-sl.org")
for header, value in res.headers.items():
print("Header: {}".format(header))
print("Value: {}".format(value))
Header: Date Value: Mon, 23 Oct 2017 19:06:30 GMT Header: Server Value: Apache Header: X-Powered-By Value: PHP/5.4.45 Header: Expires Value: Thu, 19 Nov 1981 08:52:00 GMT Header: Cache-Control Value: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Header: Pragma Value: no-cache Header: Link Value: <http://sensi-sl.org/wp-json/>; rel="https://api.w.org/", <http://sensi-sl.org/>; rel=shortlink Header: X-TEC-API-VERSION Value: v1 Header: X-TEC-API-ROOT Value: http://sensi-sl.org/wp-json/tribe/events/v1/ Header: X-TEC-API-ORIGIN Value: http://sensi-sl.org Header: Set-Cookie Value: PHPSESSID=1edc987619ba6ea90de71f914aac38cf; path=/ Header: Vary Value: Accept-Encoding,User-Agent Header: Content-Encoding Value: gzip Header: Keep-Alive Value: timeout=5 Header: Connection Value: Keep-Alive Header: Transfer-Encoding Value: chunked Header: Content-Type Value: text/html; charset=UTF-8
print(res.ok)
True
print(res.status_code)
200
print(len(res.text))
74075
non_existant = "http://sensi-sl.org/a-page-that-doesn't-exist"
res = requests.get(non_existant)
print(res.ok)
False
print(res.status_code)
404
import requests
import bs4
res = requests.get('http://sensi-sl.org/upcoming-events/')
calendar_events = bs4.BeautifulSoup(res.text, 'html5lib')
event_titles = calendar_events.select('.tribe-events-list-event-title')
print("Found {} events on the website".format(len(event_titles)))
for title in event_titles:
cleaned_title = title.getText().strip()
print(cleaned_title)
Found 8 events on the website Game Changing: Creating A Game Changing Team For Lasting Impact Possibility Mind-Set: Becoming Remarkable Data Science: Civil Society and Data Law Clinic Show and Tell: Open Interaction Nights Vultures and the City: Are Foreign Businesses Pulling Their Weight In Sierra Leone? Micro-finance and Its Impact In Africa Elections and Civil Society