Setting up
- go to python.org and download the latest version
- install Python, making sure that "add python to environment variables" is checked when you custom install Python
- to check your Python version
- at the Start window, type 'cmd'
- at the prompt, type 'python --version'
- to upgrade your pip
- at the Start window, type 'cmd'
- at the prompt, type 'python -m pip install --upgrade pip'
- to install data analysis packages, at the cmd prompt:
- type 'pip install pandas'
- type 'pip install numpy'
- type 'pip install matplotlib'
- to see which packages are installed, at the cmd prompt type 'pip list'.
- type 'IDLE' at the Start window
- CTRL+N to open a new file
- type in the module, press F5 to run and press ENTER to say yes to saving the file
- to find out where the packages are installed, run the following python code:
- to see if a particular package is installed:
- at the cmd prompt type 'pip show package_name'
- or use the following code in the IDLE window:
try: import package_name print("Package is installed.") except ImportError: print("Package is not installed.")
- or use the following code in the IDLE window:
(Note: pkg_resources is deprecated)
try: from importlib.metadata import distribution, PackageNotFoundError package = distribution("package_name") print(f"Package is installed. Package version: {package.version}") except PackageNotFoundError: print("Package is not installed.")
- to reinstall 'setuptools' and 'pip', at the cmd prompt type 'python -m pip install --upgrade setuptools pip'
- to uninstall a package, at the cmd prompt type 'pip uninstall package_name'
import site;
print(site.getsitepackages())