python how to import module

Solutions on MaxInterview for python how to import module by the best coders in the world

showing results for - "python how to import module"
Santino
29 May 2016
1#IGNORE STEP 1, 2 AND 3 IF YOU ALREADY HAVE PIP INSTALLED
2#REFER TO THE SOURCES IF YOU HAVE AN ERROR WITH YOUR PIP FOR WINDOWS
3Step 1) Go to your command terminal, (aka command prompt, MacOScommandline, Command line for linux)
4Step 2) You will have to install something called pip. 
5
6#Windows
7py -m pip install --upgrade pip #I mainly use windows
8#If an error for window says "no recognised as internal or external command"
9#Please refer to the video in the sources.
10
11#Linux
12apt-get install python3-pip
13
14#MacOs
15curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
16sudo easy_install pip
17
18step 3) #Great, now you do not need to re install, meaning do the last 2 steps
19#Ever again until you delete pip. 
20
21pip install [name of module]
22
23step 4) #implementing it into python
24
25#Method 1
26from [name of module] import [package name] #Will derrive only the package from that module
27
28#Method 2
29import [name of module] # will incorporate the whole package
30
31#How to change the name used for your packages
32
33import [name of module] as [name of your choice]
34
35from [name of module] import [package name] as [name of package of your choice]
36
37#Good luck to all my future Software engineers.
Claudio
23 Oct 2016
1import random
2from os import name, system
3import time as t
Ethan
18 Jan 2017
1import numpy as np
2import pandas as pd
3import matplotlib.pyplot as plt