How to make PyCharm recognise numpy - numpy

PyCharm does not see my numpy: thats what i got when Im trying - pip install numpy -
Requirement already satisfied: numpy in /Users/ruslanpilipyuk/opt/anaconda3/lib/python3.7/site-packages (1.18.1)
However, when I write import numpy,as a result I got -
ModuleNotFoundError: No module named 'numpy'
Im using mac

Whenever you import a module, python will search for that module in some specific directories. To know which all directories it will search, use the below given code in python prompt.
$ import sys
$ print(sys.path)
If your NumPy module does not present in any of those directory, then add your NumPy module to the python search path by the following given code in python prompt.
​
$ import sys
$ sys.path.append("/Users/ruslanpilipyuk/opt/anaconda3/lib/python3.7/site-packages (1.18.1)")
$ import NumPy
Hope this will solve your error.
Reference: https://www.edureka.co/community/66413/import-numpy-as-np-importerror-no-module-named-numpy

Related

ModuleNotFoundError: No module named 'numpy' AWS SageMaker Studio Lab

I installed the numpy with Conda, pip and pip3, also tried installing from the requirements.txt file but I am still getting the following issue. Has anyone encountered this before and could please kindly suggest something?
ModuleNotFoundError Traceback (most recent call last)
/tmp/ipykernel_732/1818554654.py in
1 import os
----> 2 import numpy as np
3 import matplotlib.pyplot as plt
4 import pandas as pd
5 import random
ModuleNotFoundError: No module named 'numpy'
numpy is built-in the default:Python environment in Studio Lab. If you open a new notebook with the File -> New -> Notebook, and choose the default:Python kernel, you should be able to import numpy without having to install the package.
If you would like to have a reproducible environment with a set of packages, see this sample repo on creating custom environments.
Numpy isn't preinstalled as a module you will need to install it yourself using pip or conda. Using notebooks just include a code block with the following:
!python -m pip install numpy
Suggestion to compile a list of required modules in a 'requirements.txt' file and install using:
!python -m pip install -r requirements.txt
Just as an FYI, the base package list is as follows:
Python 3.9 bzip2 build-essential curl git libgl1-mesa-glx nano rsync
unzip wget ca-certificates pip ipykernel-6.4
Have a look at this link for more info.
SageMaker - Manage your environment

ValueError: not enough values to unpack (expected 2, got 1) when I try to import numpy in python3

I have python3.7.4 installed and when I install numpy using pip3 it says installation is successful. When I am in my main directory I run python3 and type in import numpy and it works fine . However, when I cd into my python3 directory where I keep all my .py files and I try to run a python file that imports numpy I get an . If I am in this python3 directory and I run python3 I open the same version of python however when I try to run import numpy I get the same . My homework3.py file only contains one line which is import numpy as np just to see if it runs which it does not.
I had a file in the same directory where Python is installed with the same name as "numbers.py" so I deleted the extra file and everything worked fine.

Problems with using numpy libraries with anaconda environment on Ubuntu platform

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.

i cant import numpy in pycharm and its showing errors even after running pip install numpy in cmd

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

ImportError: Install xlrd >= 0.9.0 for Excel support when using pd.readexcel to read .xlsx file : never happened before

Something strange is going on. Just today when trying to read in a dataframe from an xlsx file:
import pandas as pd
df = pd.read_excel('vlnew.xlsx',sheet_name='Sheet1')
I am getting the following error:
ImportError: Install xlrd >= 0.9.0 for Excel support
I am fully aware that plain and simple the instructions are to install xlrd, but I should not have to install xlrd when I was never getting this error before, and also, xlrd only applies to the old .xls file format. I am using .xlsx.
I can't understand why today all of a sudden this error is popping up. This is very strange indeed, at least to me.
Update:
When I execute this script in the Spyder IDE, I do not get the xlrd import error, but just today I ran this script in the Conda command prompt and only then does it report the xlrd error. Why are there inconsistencies between the Conda command prompt and Spyder IDE?
Try writing following command into the terminal
pip install xlrd
And then import the xlrd alongside with pandas
import xlrd and import pandas as pd
I was getting an error "ImportError: Install xlrd >= 1.0.0 for Excel support" on Pycharm for below code
import pandas as pd
df2 = pd.read_excel("data.xlsx")
print(df2.head(3))
print(df2.tail(3))
Solution : pip install xlrd
It resolved error after using this.
Also no need to use "import xlrd" in program
(2021.01.18)
NOTICE: the current version of "xlrd" reads only ".xls" files
to read ".xlsx" files install openpyxl package.
Just do it in your phyton frame (my is "repl.it") writing
import xlrd
or
openpyxl_
NOTICE: the current version of "xlrd" reads only ".xls" files
As mentioned by you and others correctly that xlrd needs to be installed, for using read_excel we require xlrd package.
This might be one of the possibility of compatibility difference between spyder and conda is that you might be using different conda environments for Spyder and prompt, one of which might contain xlrd package and other did not this has happens usually when we use different virtual environments for our work , it has happened to me many times.
You should try
pip install --upgrade xlrd
juste type
pip install xlrd
and use it like this
import xlrd
import pandas as pd
data=pd.read_excel('titanic3.xls')