Install python modules/package using IDLE on Windows

Question:

I have a python script and begins as (just a part of it) –

import requests
from bs4 import BeautifulSoup
import itertools
import io
import re
import smtplib, os

Now, when I run it, it says missing requests module.

I’ve downloaded & installed 3 versions of Python from python.org, but still it seems that the packages are not installed. Can anyone tell me how to install modules using IDLE on Windows 7.

Versions I have – 2.7.8, 3.3.5, 3.4.2.

Asked By: PalashV

||

Answers:

you can use pip(a package manager for python) to install dependencies .
check this link :
https://pip.pypa.io/en/latest/installing.html

Answered By: Alibi Ghazi

You can find Windows binaries for Python packages here:

http://www.lfd.uci.edu/~gohlke/pythonlibs/

It’s just install.


Or you can use pip:

https://pip.pypa.io/en/latest/installing.html

Add pip to the system path and run commands on cmd, example:

pip install numpy

More info to install pip:

How do I install pip on Windows?


Answered By: João Paulo

Open command prompt and type

C:UsersImtiaz ChowdhuryScriptspip

install requests here.

C:usersImtiaz Chowdhury is my file path and requests is my module name; you can specify yours.

Ensure that you have pip.exe file in the specified scripts folder.

Answered By: Imtiaz Chowhdhury

Under present versions of Python (version 3.4 or above), do the following:

Windows

At the command prompt enter

py -3 -m pip install BeautifulSoup4

Linux

At the terminal enter

sudo python3 -m pip install BeautifulSoup4
Answered By: TheHolyDarkness

In Windows you should, like in Linux, use the command prompt to install your packages using pip. However, for this to work the Python executable must be in the system path. Also, all your different versions of Python need the packages installed individually.

The issue is that in the installations of all the different versions of Python, all of them have a executable called python.exe i.e. same name!

Thus, you need to rename them, for example, to python27, python33, etc. to access them individually. By renaming them and calling “pythonXX” in cmd prompt this can be done, otherwise, cmd will just take the first instance of python.exe in the system path when “python” is called in cmd.

This is particularly problematic if Anaconda2 is also installed because all packages will just there. Once you are able to run your different versions of Python from the command line you should be able to install packages correctly using pip.

In summary:

  • Rename python.exe to pythonXX.exe
  • Add the folder in which pythonXX.exe is located to the system path (see below)
  • Start cmd prompt and write “pythonXX -m pip install -U pip” – This command updates pip. If it dosen’t work restart the computer to update path and try again.
  • Now you should be able to install packages into the correct versions using pip.
  • Note that you should write e.g. “pythonXX -m pip install -U scikit-learn” to install your libraty.

Once the packages are installed into the right folders, they should also be available from IDLE and you are ready to go.

To access system path in Windows

  1. Go to Control Panel
  2. Select “System” from the context menu.
  3. Click “Advanced system settings”
  4. Go to the “Advanced” tab
  5. Click “Environment Variables…”
  6. Click variable called “Path” and click “Edit…”
  7. Click “New”
  8. Enter the path to the folder containing the executable you want on your PATH. For example, to add python33.exe, add: “C:Python33” or what your path to python33.exe is.
Answered By: NDM

This is how I would do it.

  1. Right-click command prompt from Start, and run it as administrator
  2. Write the command: cd C://Python27/Scripts
  3. Hit enter
  4. Write the pip install command: pip install requests
  5. Hit enter
  6. Voila it’s installed now.
Answered By: Joel Jogy

All warnings aside about how it should be done, you can use pip as a module in IDLE:

import pip
pip.main(['help'])
pip.main(['install', 'requests'])

It is not recommended, but it is possible, though you are likely to get errors about access to the site packages folder.

Answered By: Klaus Wik
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.