我已經在我的Mac中安裝了python。當我在終端輸入python3
,然後導入請求和bs4時,它會導入它並正確運行程序。 但是,當我在Python文件運行它python3 file_name.py
,它提供了以下錯誤:Python請求和beautifulsoup模塊不導入
import requests
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests/__init__.py", line 52, in <module>
from .packages.urllib3.contrib import pyopenssl
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests/packages/__init__.py", line 27, in <module>
from . import urllib3
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests/packages/urllib3/__init__.py", line 8, in <module>
from .connectionpool import (
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests/packages/urllib3/connectionpool.py", line 3, in <module>
import logging
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/logging/__init__.py", line 28, in <module>
from string import Template
File "/Users/dark_archer/Desktop/src/string.py", line 1, in <module>
n1,n2=map(int,input().split())
ValueError: not enough values to unpack (expected 2, got 0)
我既蟒蛇3.5和3.6蟒得到了同樣的錯誤。
當你運行你的腳本它提示你輸入或立即失敗而不需要您採取任何行動?你得到的錯誤表明你沒有從標準輸入中得到任何輸入,所以沒有什麼可以分配給'n1'和'n2'。 – 2016-12-29 07:49:36
在程序文件中我只寫了'import requests' – Abhishek