2

Our homework requires us to install prettytable, but I tried many times and failed to install.

Can anyone tell me how to do it?

I used following ways:

from prettytable import PrettyTable

Error:

No module named 'prettytable'

import prettytable

I even downloaded it from online.

from prettytable import PrettyTable

Error:

No module named 'prettytable'

And:

import prettytable

Error:

No module named 'prettytable'
U13-Forward
  • 69,221
  • 14
  • 89
  • 114
Sandy
  • 359
  • 4
  • 14

1 Answers1

2

The error message

No module named 'prettytable'

means the module is not installed for your Python. You can only import a module that's installed. A module can be installed by Python default (that's called built-in modules), or explicitly by yourself, or when you install another module.

To install prettytable for your conda environment,

run conda install -c conda-forge prettytable from your terminal (command line). Then you will see a bunch of command line instructions. Read carefully, and hit 'y' when you are asked to proceed. If the installation is successful, the process will end with some lines like

Downloading and Extracting Packages

prettytable-0.7.2 | 14 KB | ##################################### | 100%

Preparing transaction: done

Verifying transaction: done

Executing transaction: done

Then you open python (or Jupyter or whatever you use to run python) and try import prettytable again.

Community
  • 1
  • 1
Ignatius
  • 2,745
  • 2
  • 20
  • 32
  • It is said: Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:44:40) [MSC v.1600 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> conda install -c conda-forge prettytable File "", line 1 conda install -c conda-forge prettytable ^ SyntaxError: invalid syntax >>> – Sandy Mar 29 '19 at 03:37
  • Your Start menu > type "anaconda prompt" > open the application > type `conda install -c conda-forge prettytable` – Ignatius Mar 29 '19 at 03:38
  • Which command line? I used Python 3 Python Command Line, is that right? – Sandy Mar 29 '19 at 03:39
  • Anaconda Prompt – Ignatius Mar 29 '19 at 03:40
  • It said: 'conda' is not recognized as an internal or external command, operable program or batch file. – Sandy Mar 29 '19 at 03:41
  • Then your anaconda is broken. Re-install it. – Ignatius Mar 29 '19 at 03:43