I have brew install python2 for OsX, then I install numpy, scipy using pip install.
I also need python3, so I brew install python3, but when I import numpy under python3, import error occurs.
I known I can fix this by install numpy using pip3 install numpy, but do I have to do this? Since I have the package already installed for python2, can I just tell python3 where it is and then use it?
Yes you need to install them using pip3 as well as python3.4 bundles pip in along side of python
Related
I installed Ubuntu 20.04, and python3 (3.8) is installed by default.
To install python3.9, I executed:
sudo apt install python3.9
Thus, I have two versions of Python at my laptop: 3.8 and 3.9.
I'm trying to launch the simple script:
import numpy
With Python 3.8 it works correctly. But, when I interp my script by Python 3.9 the error occurs:
How to solve this problem?
I've already tried to update numpy using pip, nothing has happened.
pip3 install numpy --upgrade
Likely what is happening here is, because you have 2 versions of python installed, your pip3 command is only installing things for one of the versions, 3.8 in this case.
Specifying the python version you want to run your command with will help solve this issue.
For example,
python3.9 -m pip install numpy
or
python3.8 -m pip install numpy
You can install a package for a specific version of Python with
python3.9 -m pip install numpy
For a more consistent python environment look at python venv or a container.
I am new to Python and I have to use Python 3.3.1 version instead of latest one...
pip install numpy
it returns
SyntaxError: invalid syntax
I tried using the way i installed on python 3.6 but seems to be not working here..
I don't know how to install packages like numpy, pandas, scipy, sci-kit learn, matplotlib etc... in the Python 3.3.1, could you please help..?
Do i need to install pip separately... ?
Thanks in advance.
If you are in window try with:-
Open CMD and
python -m pip install numpy
If this is not working try with this
just type it as your python programe and run it
import pip
pip.main(["install","numpy"])
In my windows 10 machine, the pip.exe is in C:\Python36\Scripts folder. So I install required packages by either using command C:\Python36\Scripts\pip install package_name or first cd C:\Python36\Scripts and then pip install package_name. So far it worked me in different versions of pythons installed.
As suggested by ostue, please make sure that pip is installed with the python distribution.
I am able to install tensorflow for python using pip just fine but when I try and install tensorflow for pypy using:
pypy -m pip install --upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.9.0-py2-none-any.whl
I get error messages about how pypy doesn't play well with numpy. I already have numpy installed for pypy and it workes fine. I can do
pypy
>>>>import numpy
without any errors.
What am I doing wrong here? Is there a way to try and install tensorflow without it trying to install numpy? Has anyone done this before?
youcan use directly pip
example: Mac OS X, CPU only - py2
export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/tensorflow-0.9.0-py2-none-any.whl
sudo pip install --upgrade $TF_BINARY_URL
If you need validate pip installation:
sudo easy_install pip
sudo easy_install --upgrade six
If you need info for other SO or more details you can see here
I have been literally struggling to install numpy for python 2.7 and not 3.4 both of which are on my ubuntu. I have tried:
sudo pip2 install numpy
but it says
Requirement already satisfied (use --upgrade to upgrade): numpy in /usr/lib/python2.7/dist-packages
but when I go to the python shell, and type import numpy, it throws an ImportError
python --version prints `Python 2.7.5`
I have no idea what the problem is even after looking at various answers to other SO questions. Is numpy installed and I'm not able to use it for some reason or isn't it installed? Please help.
First, do pip uninstall numpy and pip2 uninstall numpy just to clean up any old files.
Then, since you are on Ubuntu, you should just run
sudo apt-get install python-numpy
This will install numpy for python2. If you later choose you want it for python3, just run
sudo apt-get install python3-numpy
sudo pip2 install numpy==1.15.0
You need to specify numpy version because latest version requires Python version >= 3.5.
After an hour search, I have found no answer.
My Mac came with Python 2.7, but I have decided to upgrade to python 3.4.
I installed python 3.4 from python.org.
I can now use python 3.4 from terminal.
Pip still tries to download python 2.7 packages - numpy for 2.7 is "up to date".
When I try to --upgrade a package, for example numpy, I get "no permission" error. With sudo appended, the output is trash.
How can I let pip know that I am interested in packages for python 3.4?
Requirement already up-to-date: numpy in /Library/Python/2.7/site-packages
That's the problem. I want numpy to be up-to-date with Python 3.4.
You should be able to call a specific pip for your install, although it depends on which version you are running:
Starting at version 0.8:
pip-3.4 install numpy
and starting at version 1.5:
pip3.4 install numpy
If you don't have these, you should be able to just download pip and reinstall it, just be sure to call python 3.4 when you run the installer.
I would suggest to install a package manager such as macports brew and install the updated python version from them. After the latest version of python is setup use pip to install the version of numpy
In mac ports , you are able to select the default system python without messing with the path your self.
I would use Homebrew:
brew install python3
This should install Python3.4.1. Then to get pip:
curl -O https://raw.github.com/pypa/pip/master/contrib/get-pip.py
sudo python3 get-pip.py
# Upgrade just in case...
pip3 install -U pip
Then use:
pip3 install numpy
And to run Python, use:
python3
(I only have one Python 3 installation, if you have multiple you'll need to be more specific with the version number)