Python import module error ImportError: No module named 'request'

try to solve the problem without success. If you ask for help, it should be a soft connection problem

.

1. The installed requests, should be in the wrong python path (python-v python is 2.7. No, no, no. )

2.python3.6 brew install python

3.

4.

Mar.02,2021

pip3 installs the module under python3, while running python may actually start python2

the easiest way is to use the soft link python3 instead of python.

those who are willing to do it can use the following method:
mac comes with python under / System/Library/Frameworks/Python.framework and / usr/bin/python , because the operating system itself needs to be used, so it doesn't want you to change it to another version. But you can modify the soft links under / usr/local/bin .
also modifies the PATH variable (such as through the ~ / .bashrc file) so that / usr/local/bin comes first. So you can use the version you want in the terminal.


you can explicitly specify -sharphammer test.py python3.6 at the beginning of the script; in this way, the script will be run using python3.6.
install an anaconda if you need to have multiple versions of python

Menu