1
  module = importlib.import_module(module_str)
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 848, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed

when I tried to import some of the modules like pandas, pymysteams and ... i am getting this error ModuleNotFoundError

I am creating a virtual env using virtualenv myvenv

whats causing this error help me to figure it out

pip list

Package            Version
------------------ ---------
aioredis           2.0.1
aiosmtplib         1.1.7
anyio              3.6.2
async-timeout      4.0.2
blinker            1.5
boto3              1.26.17
botocore           1.29.17
certifi            2022.12.7
charset-normalizer 2.1.1
dnspython          2.2.1
email-validator    1.3.0
fastapi            0.87.0
fastapi-mail       1.2.2
greenlet           2.0.1
idna               3.4
Jinja2             3.1.2
jmespath           1.0.1
MarkupSafe         2.1.1
mongoengine        0.24.2
numpy              1.24.0
pandas             1.5.2
pip                22.3.1
pydantic           1.10.2
pymongo            4.3.3
python-dateutil    2.8.2
python-dotenv      0.21.0
pytz               2022.7
requests           2.28.1
s3transfer         0.6.0
setuptools         65.6.3
six                1.16.0
sniffio            1.3.0
SQLAlchemy         1.4.17
sqlalchemy2-stubs  0.0.2a29
sqlmodel           0.0.8
starlette          0.21.0
typing_extensions  4.4.0
urllib3            1.26.13
wheel              0.38.4

my requirments.txt file and am using these version is that maters.

-i https://pypi.org/simple
aioredis==2.0.1
boto3==1.26.17
botocore==1.29.17
fastapi==0.87.0
fastapi_mail==1.2.2
mongoengine==0.24.2
pydantic==1.10.2
python-dotenv==0.21.0
requests==2.28.1
SQLAlchemy==1.4.17
starlette==0.21.0
sqlmodel==0.0.8
PyMySQL==1.0.2
pandas==1.5.2

pip3 install pandas, pip install pandas, both are not effected

Thanks

putta
  • 35
  • 8
  • yes this site and using these commands it solved thanks curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py python3 get-pip.py sudo python3 -m pip install pandas – putta Dec 20 '22 at 06:33

1 Answers1

1

When there are multiple versions of Python (and pip) installed, it can be confusing about which package versions are installed where. There is an easy disconnect between Python and pip.

So an easy way to bridge the disconnect is invoking pip via Python. To make sure you are invoking the pip associated with a certain version of Python, invoke pip as follows:

python -m pip <whatever args you are going to pass to pip>

So, to check for this disconnect, compare the output of:

pip list 

with:

python -m pip list

If they differ, you know you've got that common disconnect.

You can also run:

pip --version

to see in which Python dir pip is located. On my machine, I run Py3.8 32-bit version for compatibility purposes, and I get the following output:

pip 22.3.1 from c:\python\python38-32\lib\site-packages\pip (python 3.8)

And of course, you can run a command which explicitly points to a particular version of Python, like:

C:\Python\Python38-32\python.exe -m pip install numpy pandas
GaryMBloom
  • 5,350
  • 1
  • 24
  • 32