I cannot install package in Python.For example the package numpy or pandas.I download the python today. I press import numpy as np and nothing
3 Answers 3
You have to install it first. Search "Python Pip" on google and download Pip. Then use that to open CMD and type "pip install (Module)". Then it should import with no errors.
Comments
first install pip (for example in ubuntu use either of the following)
$> sudo apt install python-pip #python 2
$> sudo apt install python3-pip #python 3
Now install the python package (for example numpy)
pip install numpy
This is the simplified version. Now if you need python for something like datas science then install anaconda ( which has libaries like numpy, pandas etc bundled together)
- go to anaconda website and download the anaconda version that you need
- Open terminal window and navigate to the download directory
run the following command (use sh instead of bash depending on flavor of Linux). Assuming yours is a 64bit machine and you downloaded corresponding package then you would have downloaded the corresponding file:
bash Anaconda-latest-Linux-x86_64.shfollow the instructions on the screen
quick documentation to Anaconda installation is here
Comments
If you are going to set up Python for Data Science or Machine Learning as you have mentioned about Numpy & Pandas, so it looks like you are going to set up Python for Data Science OR Machine Learning. The best and professional way is using the Anaconda.
Anaconda is a python and R distribution. It aims to provide everything you need for data science or Machine Learning "out of the box" for Python also.
It includes:
- The core python language
- 100+ python "packages" (libraries)
- Spyder (IDE/editor - like pycharm) and Jupyter
- conda, Anaconda's own package manager, used for updating Anaconda and packages
So, You can easily install it: You can easily download and install from here: https://www.anaconda.com/distribution/
If you are on Windows OS then you can follow this guide:
https://hackernoon.com/installing-python-and-anaconda-on-windows-f9059ba8b136
In case of Linux/Ubuntu go ahead here:
https://www.digitalocean.com/community/tutorials/how-to-install-anaconda-on-ubuntu-18-04-quickstart
And for MAC OS installation log on here:
ImportError?