question

AliMahd-2381 avatar image
3 Votes"
AliMahd-2381 asked AnnaManzoni-2374 commented

ModuleNotFoundError: No module named 'pandas' when import pandas

I have installed Anaconda and pandas are installed in a particular directory location. However when I run my Python script in Visual Studio Code the "import pandas as pd" returns the error above. Do I have to install pandas in another location next to Python.exe? If so how? I have tried installing pandas again in Anaconda and it returns with message that requirement already satisfied. I cannot run "pip install pandas" from CMD. It does not recognise pip as an internal or external command.
I will be grateful if you can help.

not-supported-azure
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @AliMahd-2381, This article might help you.

1 Vote 1 ·
EvanChatter-2929 avatar image
0 Votes"
EvanChatter-2929 answered EvanChatter-2929 edited

In most cases this error in Python generally raised:

  • You haven't installed Pandas explicitly with pip install pandas.

  • You may have different Python versions on your computer and Pandas is not installed for the particular version you're using.

You can run the following command in your Linux/MacOS/Windows terminal.

 pip install pandas

To be sure you are not having multiple Python versions that are confusing, you should run following commands:

python3 -m pip install pandas
python3 -c 'import pandas'




5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

josehenriquediasferreira-1833 avatar image
0 Votes"
josehenriquediasferreira-1833 answered AnnaManzoni-2374 commented

Hello, if you still haven't solved it, I would ask you to check the version of your python, using the command "python -version" in your cmd, and then install the plugin using the same cmd as well, do this through anaconda prompt, make it be installed in an instance to use only anaconda if I'm not mistaken. After checking your python version, open your script using visual studio and if you are developing on a notebook, change the python version in the upper right corner, to a version greater than or equal to the one installed103943-screenshot-2.png


To get pip to work on your cmd, try reinstalling your python by checking "add python version to PATH".

HtYbw.png



Hope to help!


screenshot-2.png (74.1 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks @ josehenriquediasferreira-1833

What also helped me was to use wheel to distribute it:

 pip install wheel
 pip install pandas

I was trying to import this lib as well to use some functions like nunique Pandas dataframe and run into the similar error:

 F:\> pip install pandas
 Collecting pandas
 c:\python27\lib\site-packages\pip\_vendor\requests\packages\urllib3\util\ssl_.py
 :90: InsecurePlatformWarning: A true SSLContext object is not available. This pr
 events urllib3 from configuring SSL appropriately and may cause certain SSL conn
 ections to fail. For more information, see https://urllib3.readthedocs.org/en/la
 test/security.html#insecureplatformwarning.
 
   error: invalid command 'bdist_wheel'
    
    
 F:\>python tweet_fetcher.py
 Traceback (most recent call last):
   File "tweet_fetcher.py", line 1, in <module>
     import pandas
 ImportError: No module named pandas





0 Votes 0 ·