In shell I can't install numpy and it shows this error
The problem is that you are typing 'shell' (operating system) commands into the Python interpreter, which only understands Python.
First, exit the Python interpreter with exit().
Then type the shell command, pip install numpy.
Then you can re-enter the Python interpreter, e.g. by typing python and you should have access to NumPy with import numpy as np (for example).
Related
I am trying to plot an image in python using either PIL or Matplotlib. I have tried both
import matplotlib.pyplot as plt
and
from PIL import Image
But I get the same error:
ImportError: cannot import name '_imaging' from 'PIL'
I have updated pillow and matplotlib packages but no success
You can read the image using open cv and then plot it using matplotlib.
img_name = cv2.imread("image.jpeg")
plt.imshow(img_name)
plt.show()
This usually happens when folk use python and pip from different packages, distributions or versions. I mean you install a package with pip into one package/distribution/version and then try and use it from a different package/distribution/version of Python.
So, if you normally start Python using:
python
then run:
type python
Whereas if you normally start Python using:
python3
then run:
type python3
On my machine I get:
type python3
python3 is /Library/Frameworks/Python.framework/Versions/3.9/bin/python3
so now I know which Python I am using.
Now you need to see which pip you are using. So, if you normally start pip with:
pip
then run:
type pip
Whereas if you normally start pip with:
pip3
then run:
type pip3
On my machine I get:
type pip3
pip3 is /Library/Frameworks/Python.framework/Versions/3.9/bin/pip3
So now you can see that my pip3 is installing packages for python3 exactly where it can find them.
I am using anaconda 3. When I try to import pandas I receive the following message:
ImportError: this version of pandas is incompatible with numpy < 1.15.4
your numpy version is 1.15.3.
Please upgrade numpy to >= 1.15.4 to use this pandas version
Printing numpy.__path__ gives me the following
['C:\Users\andrei\AppData\Roaming\Python\Python37\site-packages\numpy']
In conda list, my numpy version is 1.19.1. I checked the above directory to find that it has only numpy 1.15.3 inside and nothing else. Spyder is using this path instead of the anaconda's path to numpy for some arcane reason.
Looks like you have somehow installed several versions of NumPy. Try to remove them all by running several times conda remove numpy and pip uninstall numpy. If you have two versions, the corresponding uninstall command needs to be run twice. After these, install a fresh version of NumPy conda install numpy
You can verify if you still have a version of NumPy installed
conda list | grep numpy
pip list | grep numpy
Note that these commands show only one version number even if you have several copies installed.
You can use conda to upgrade to upgrade your numpy. Run this command in the terminal:
conda update numpy
You need to remove this directory
C:\Users\andrei\AppData\Roaming\Python\
to fix this problem. It seems at some point you used pip to install numpy and that's interfering with the packages installed by conda (which is reporting the right version, as you said).
Furthermore, please be aware that pip and conda packages are binary incompatible, so you should avoid as much as possible to mix them.
new to python and trying to learn some data science, Ive downloaded python 3.8.3 for windows64 two the few things I learned at during the short free trial.
when trying to install numpy I received a syntax error, even though pip was imported and the path is shown.
>>> pip
<module 'pip' from 'C:\\Users\\owner\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-
packages\\pip\\__init__.py'>
>>> pip install numpy
SyntaxError: invalid syntax
typing python in windows command prompt just brings up the windows store on the python app, and typing pip doesn't find anything as well.
C:\Users\owner>pip
'pip' is not recognized as an internal or external command,
operable program or batch file.
in general, it seems that none of the commands that aren't print() or help() is working.
what did I do wrong?
Make sure that you add Python to System Environment PATH when you are installing python.
If you didn't try this command to add it to your PATH
setx PATH "%PATH%;C:\Python34\Scripts"
I am working on the Ubuntu platform and have downloaded the numpy libraries using the following command in the terminal:
>> conda install -c anaconda numpy
and then tried to import the numpy library as np as follows:
>> import numpy as np
now this command gives out the "ModuleNotFoundError" as follows:
Output on the spyder console
I know it looks like a basic question but I'm learning.
Thank you.
You should first enter into the ipython console by 'ipython' command in terminal, then 'import numpy as np' will work.
even after trying pip install numpy in cmd i cannot get the numpy module installed in pycharm.
i have also tried to add numpy using project interpreter.
numpy is being listed in the available modules but it cannot be installed.
The screenshot of the error is placed below. please help me out