0

Probably stupidly I tried to install the latest version of Python, in this case using the download from python site, but after doing that I was then getting python still running on the previous version python-3.6. I'm on OSX and was using sublime.

So I have been trying to work out how to update it to use the newest version. I've followed; https://opensource.com/article/19/5/python-3-default-mac.

All of the responses to queries now point to the python-3.9.5 version. So that's great and my runtime is using that. However after installing the requests using pip install I get the following error when running.

import requests
ModuleNotFoundError: No module named 'requests'''

[path: /Library/Frameworks/Python.framework/Versions/3.9/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin]

I stumbled upon Modules are installed using pip on OSX but not found when importing which I have been trying to work through.

I have been able to run the import command successfully in terminal, however it's intermittent as I've tried again and it's broken, so I'm lost. I'm running it something trying to run the python3.6 version, which after updating I followed these instructions to remove when I have uninstalled that from my mac https://www.macupdate.com/app/mac/5880/python/uninstall.

If there is any ideas, would love some help, mainly to try and tell me what that error message is telling me.

In particular, what does this mean?

[path: /Library/Frameworks/Python.framework/Versions/3.9/bin:/Library/Frameworks/Python.framework/Versions/3.6/ 

I should clarify too; when I run 'pip list'

I see requests 2.25.1

  • Was the `pip` executable you ran installing packages for the correct Python version? I prefer to use `python3.9 -m pip install requests` rather than just `pip` so there is no ambiguity as to which version of Python I am installing the package for – Iain Shelvington Jun 05 '21 at 05:40
  • Hi @Lauchlan, Can you please add more details to your question, like from where are you running the file. Is it any IDE? ,if so can you please check which python version you have set in your project settings ( Are you using any virtual environments) – Pratap Alok Raj Jun 05 '21 at 12:28
  • I think @IainShelvington nailed it with doing the pip install on the wrong python version. I tried his command and it installed and now runs fine. I have tried two IDE's (using sublime text and now VS Code) but it seems there's something weird going on with where my python is running from which is using python3.9 but then the pip install is going to the other python path – Lauchlan Robertson Jun 06 '21 at 23:48

1 Answers1

0

Assuming that you are not installing requests package properly, and assuming your python executable is named python:

python -m pip install requests

If however, your python executable is named something else instead, e.g. python3, replace python with that name:

python3 -m pip install requests
user5305519
  • 3,008
  • 4
  • 26
  • 44