1

(raspberrypi) "pandas" Requirement already satisfied, but No module named 'pandas', when I run python script ("import pandas as pd")

I use raspberrypi 4 ; 32 bit, linux run python

I run: in virtual environment

(venv) joy@raspberrypi: sudo pip install pandas
(venv) joy@raspberrypi: ython excel_to_mDB.py

(venv) joy@raspberrypi:/media/joy/DATA $ sudo pip install pandas
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: pandas in /usr/lib/python3/dist-packages (1.1.5)


(venv) joy@raspberrypi:/media/joy/DATA $ python excel_to_mDB.py
Traceback (most recent call last):
  File "/media/joy/DATA/excel_to_mDB.py", line 3, in <module>
    import pandas as pd
ModuleNotFoundError: No module named 'pandas'

  • solving on process:
    after I do pip install pandas

(venv) joy@raspberrypi:/media/joy/DATA $ pip install pandas
(venv) joy@raspberrypi:/media/joy/DATA $ python excel_to_mDB.py

(venv) joy@raspberrypi:/media/joy/DATA $ pip install pandas
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting pandas
  Using cached pandas-1.5.1.tar.gz (5.2 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error
 
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [53 lines of output]
      Traceback (most recent call last):
        File "/tmp/pip-build-env-d93of2e3/overlay/lib/python3.9/site-packages/numpy/core/__init__.py", line 22, in <module>
          from . import multiarray
        File "/tmp/pip-build-env-d93of2e3/overlay/lib/python3.9/site-packages/numpy/core/multiarray.py", line 12, in <module>
          from . import overrides
        File "/tmp/pip-build-env-d93of2e3/overlay/lib/python3.9/site-packages/numpy/core/overrides.py", line 7, in <module>
          from numpy.core._multiarray_umath import (
      ImportError: libcblas.so.3: cannot open shared object file: No such file or directory
     
      During handling of the above exception, another exception occurred:
     
      Traceback (most recent call last):
        File "/home/joy/myproject/venv/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 351, in <module>
          main()
        File "/home/joy/myproject/venv/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 333, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/home/joy/myproject/venv/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
        File "/tmp/pip-build-env-d93of2e3/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 338, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=['wheel'])
        File "/tmp/pip-build-env-d93of2e3/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 320, in _get_build_requires
          self.run_setup()
        File "/tmp/pip-build-env-d93of2e3/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 483, in run_setup
          super(_BuildMetaLegacyBackend,
        File "/tmp/pip-build-env-d93of2e3/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 335, in run_setup
          exec(code, locals())
        File "<string>", line 18, in <module>
        File "/tmp/pip-build-env-d93of2e3/overlay/lib/python3.9/site-packages/numpy/__init__.py", line 140, in <module>
          from . import core
        File "/tmp/pip-build-env-d93of2e3/overlay/lib/python3.9/site-packages/numpy/core/__init__.py", line 48, in <module>
          raise ImportError(msg)
      ImportError:
     
      IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
     
      Importing the numpy C-extensions failed. This error can happen for
      many reasons, often due to issues with your setup or how NumPy was
      installed.
     
      We have compiled some common reasons and troubleshooting tips at:
     
          https://numpy.org/devdocs/user/troubleshooting-importerror.html
     
      Please note and check the following:
     
        * The Python version is: Python3.9 from "/home/joy/myproject/venv/bin/python"
        * The NumPy version is: "1.19.3"
     
      and make sure that they are the versions you expect.
      Please carefully study the documentation linked above for further help.
     
      Original error was: libcblas.so.3: cannot open shared object file: No such file or directory
     
      [end of output]
 
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.


(venv) joy@raspberrypi:/media/joy/DATA $ python excel_to_mDB.py
Traceback (most recent call last):
  File "/media/joy/DATA/excel_to_mDB.py", line 3, in <module>
    import pandas as pd
ModuleNotFoundError: No module named 'pandas'
j ton
  • 229
  • 9

1 Answers1

2

You are installing the pandas using the command sudo pip install pandas which will install pandas into the root folder /usr/lib/python3/dist-packages see the logs in your command. You need to install pandas into the virtual environment. So install pandas without sudo.

pip install pandas
Rahul K P
  • 15,740
  • 4
  • 35
  • 52
  • hi @Rahul K P , with `pip install pandas` I still face some problem – j ton Oct 27 '22 at 05:46
  • @44chuang try [this](https://stackoverflow.com/questions/53347759/importerror-libcblas-so-3-cannot-open-shared-object-file-no-such-file-or-dire) – Rahul K P Oct 27 '22 at 05:55