Today, we use Python to download images, using urllib. Request, which is the method of Python 3. Python 2 uses urllib2
Encountered such a problem, the background reported an error, importerror: no module named request
I checked a lot of information and said that I was installing requests, but I was still like this after installation. I was almost desperate
Finally, we found a problem. The gunicorn related content displayed in the error message is python2.7
I wonder if it’s because Python 2.7 and python 3 are installed in the background, gunicorn uses Python 2.7 in the background, but urllib.request is a function of Python 3, so I can’t find the corresponding module
After analyzing the problem, then start to solve the problem
1. Look at all the directories under bin
cd /bin
2. Backup the gunicorn file inside
cp gunicorn gunicorn.bck
3. Create a soft connection of gunicorn under python3 to bin (if not, install a gunicorn with PIP3)
ln -s /usr/local/python3/bin/gunicorn /bin/gunicorn
4. You can check whether it is successful
ls -l
In this way, the background running service is python3, and the module request will not be reported again
5. If after the above problems are solved, there is a problem that the SSL module cannot be found (anyway, I have)
Please check https://www.cnblogs.com/mqxs/p/9103031.html
Similar Posts:
- No module named ‘urllib.request’; ‘urllib’ is not a package
- The solution of module ‘urllib’ has no attribute ‘request’
- Gunicorn starts with an error gunicorn.errors.haltserver
- ModuleNotFoundError No module named urllib2
- [Solved] yum Execute Error: -bash: /usr/bin/yum: /usr/bin/python3.7: bad interpreter: No such file or directory
- Python crawling picture prompt urllib.error.httperror: http error 403: forbidden solution
- How to Solve Python Error: “HTTP Error 403: Forbidden”
- Python 2.7 and 3.4 requests Error: No module named ‘zlib’
- [Solved] SQLAlchemy Error: ImportError: cannot import name ‘TYPE_CHECKING’
- Differences of urllib, urllib2, httplib and httplib2 libraries in Python