简体   繁体   中英

Why python3 can't find already installed module?

I have 2.7 and 3.7 version of Python on my MAC. I'm using Visual Studio Code as an IDE and I want to reference Yahoo Earnings module as part of my script. If I use 2.7 python version, I can build and run the script. But if I use 3.7 version of Python, I get the following error:

Exception has occurred: ModuleNotFoundError
  No module named 'yahoo_earnings_calendar'

Here's the output pip3 list command showing that I have yahoo-earnings-calendar 0.6.0 module installed

`

bash-3.2$ pip3 listPackage                 Version
----------------------- ---------
arrow                   0.14.7
certifi                 2020.6.20
chardet                 3.0.4
ics                     0.7
idna                    2.10
pip                     20.1.1
python-dateutil         2.8.1
requests                2.24.0
setuptools              47.1.0
six                     1.15.0
TatSu                   5.5.0
urllib3                 1.25.10
**yahoo-earnings-calendar 0.6.0**

I'll be happy if someone can assist me to find out what may cause this issue.

You might have multiple versions of python3 on your system. I for instance have both python 3.7 and 3.6 on my system. if i use pip3 it installs the packages in my version 3.6 install.

by running

pip3 --version

you can see which version of python pip3 is comming from in my case: 3.6

pip 19.3.1 from /home/andreas/.local/lib/python3.6/site-packages/pip (python 3.6)

make sure to use the right version of python when using the module

in my case if i want to use pip3 modules i need to write

python3.6 someprogram.py

when running a program

because if i just write

python someprogram.py

it uses python 3.7 and the module will therfore not be available

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM