折腾:
【已解决】Python中用pandas读取excel文件并解析得到数据
期间,当前python版本是:
pyenv global 3.7.3 pyenv versions system 3.5.2 3.6.6 * 3.7.3 (set by /Users/crifan/.pyenv/version)
然后去安装pandas,结果报错:
pipenv install pandas Creating a virtualenv for this project… Pipfile: /Users/crifan/dev/dev_root/projects/团队业绩统计/TeamSaleStatistic/Pipfile Using /Users/crifan/.pyenv/versions/3.7.3/bin/python3 (3.7.3) to create virtualenv… ⠋ Creating virtual environment...created virtual environment CPython3.7.3.final.0-64 in 710ms creator CPython3Posix(dest=/Users/crifan/.local/share/virtualenvs/TeamSaleStatistic-VIYlkgMt, clear=False, global=False) seeder FromAppData(download=False, pip=latest, setuptools=latest, wheel=latest, via=copy, app_data_dir=/Users/crifan/Library/Application Support/virtualenv/seed-app-data/v1) activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator ✔ Successfully created virtual environment! Virtualenv location: /Users/crifan/.local/share/virtualenvs/TeamSaleStatistic-VIYlkgMt Installing pandas… Adding pandas to Pipfile's [packages]… ✔ Installation Succeeded Pipfile.lock not found, creating… Locking [dev-packages] dependencies… Locking [packages] dependencies… ✘ Locking Failed! [pipenv.exceptions.ResolutionFailure]: File "/Users/crifan/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pipenv/resolver.py", line 69, in resolve [pipenv.exceptions.ResolutionFailure]: req_dir=requirements_dir [pipenv.exceptions.ResolutionFailure]: File "/Users/crifan/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pipenv/utils.py", line 726, in resolve_deps [pipenv.exceptions.ResolutionFailure]: req_dir=req_dir, [pipenv.exceptions.ResolutionFailure]: File "/Users/crifan/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pipenv/utils.py", line 480, in actually_resolve_deps [pipenv.exceptions.ResolutionFailure]: resolved_tree = resolver.resolve() [pipenv.exceptions.ResolutionFailure]: File "/Users/crifan/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pipenv/utils.py", line 395, in resolve [pipenv.exceptions.ResolutionFailure]: raise ResolutionFailure(message=str(e)) [pipenv.exceptions.ResolutionFailure]: pipenv.exceptions.ResolutionFailure: ERROR: ERROR: Could not find a version that matches pandas [pipenv.exceptions.ResolutionFailure]: No versions found [pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies. First try clearing your dependency cache with $ pipenv lock --clear, then try the original command again. Alternatively, you can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation. Hint: try $ pipenv lock --pre if it is a pre-release dependency. ERROR: ERROR: Could not find a version that matches pandas No versions found Was https://pypi.org/simple reachable? [pipenv.exceptions.ResolutionFailure]: req_dir=requirements_dir [pipenv.exceptions.ResolutionFailure]: File "/Users/crifan/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pipenv/utils.py", line 726, in resolve_deps [pipenv.exceptions.ResolutionFailure]: req_dir=req_dir, [pipenv.exceptions.ResolutionFailure]: File "/Users/crifan/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pipenv/utils.py", line 480, in actually_resolve_deps [pipenv.exceptions.ResolutionFailure]: resolved_tree = resolver.resolve() [pipenv.exceptions.ResolutionFailure]: File "/Users/crifan/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pipenv/utils.py", line 395, in resolve [pipenv.exceptions.ResolutionFailure]: raise ResolutionFailure(message=str(e)) [pipenv.exceptions.ResolutionFailure]: pipenv.exceptions.ResolutionFailure: ERROR: ERROR: Could not find a version that matches pandas [pipenv.exceptions.ResolutionFailure]: No versions found [pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies. First try clearing your dependency cache with $ pipenv lock --clear, then try the original command again. Alternatively, you can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation. Hint: try $ pipenv lock --pre if it is a pre-release dependency. ERROR: ERROR: Could not find a version that matches pandas No versions found Was https://pypi.org/simple reachable?

pipenv Could not find a version that matches pandas
那先进去shell
pipenv shell Launching subshell in virtual environment… . /Users/crifan/.local/share/virtualenvs/TeamSaleStatistic-VIYlkgMt/bin/activate
再去安装:
pipenv install pandas 。。。 [pipenv.exceptions.ResolutionFailure]: No versions found [pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies. First try clearing your dependency cache with $ pipenv lock --clear, then try the original command again. Alternatively, you can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation. Hint: try $ pipenv lock --pre if it is a pre-release dependency. ERROR: ERROR: Could not find a version that matches pandas No versions found Was https://pypi.org/simple reachable?
问题依旧。
其中:
[pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies. First try clearing your dependency cache with $ pipenv lock --clear, then try the original command again. Alternatively, you can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation. Hint: try $ pipenv lock --pre if it is a pre-release dependency. ERROR: ERROR: Could not find a version that matches pandas
那分别去试试看看
pipenv lock --clear Locking [dev-packages] dependencies… Locking [packages] dependencies… ✘ Locking Failed! [pipenv.exceptions.ResolutionFailure]: File "/Users/crifan/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pipenv/resolver.py", line 69, in resolve [pipenv.exceptions.ResolutionFailure]: req_dir=requirements_dir [pipenv.exceptions.ResolutionFailure]: File "/Users/crifan/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pipenv/utils.py", line 726, in resolve_deps [pipenv.exceptions.ResolutionFailure]: req_dir=req_dir, [pipenv.exceptions.ResolutionFailure]: File "/Users/crifan/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pipenv/utils.py", line 480, in actually_resolve_deps [pipenv.exceptions.ResolutionFailure]: resolved_tree = resolver.resolve() [pipenv.exceptions.ResolutionFailure]: File "/Users/crifan/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pipenv/utils.py", line 395, in resolve [pipenv.exceptions.ResolutionFailure]: raise ResolutionFailure(message=str(e)) [pipenv.exceptions.ResolutionFailure]: pipenv.exceptions.ResolutionFailure: ERROR: ERROR: Could not find a version that matches pandas [pipenv.exceptions.ResolutionFailure]: No versions found [pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies. First try clearing your dependency cache with $ pipenv lock --clear, then try the original command again. Alternatively, you can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation. Hint: try $ pipenv lock --pre if it is a pre-release dependency. ERROR: ERROR: Could not find a version that matches pandas No versions found Was https://pypi.org/simple reachable? [pipenv.exceptions.ResolutionFailure]: req_dir=requirements_dir [pipenv.exceptions.ResolutionFailure]: File "/Users/crifan/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pipenv/utils.py", line 726, in resolve_deps [pipenv.exceptions.ResolutionFailure]: req_dir=req_dir, [pipenv.exceptions.ResolutionFailure]: File "/Users/crifan/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pipenv/utils.py", line 480, in actually_resolve_deps [pipenv.exceptions.ResolutionFailure]: resolved_tree = resolver.resolve() [pipenv.exceptions.ResolutionFailure]: File "/Users/crifan/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pipenv/utils.py", line 395, in resolve [pipenv.exceptions.ResolutionFailure]: raise ResolutionFailure(message=str(e)) [pipenv.exceptions.ResolutionFailure]: pipenv.exceptions.ResolutionFailure: ERROR: ERROR: Could not find a version that matches pandas [pipenv.exceptions.ResolutionFailure]: No versions found [pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies. First try clearing your dependency cache with $ pipenv lock --clear, then try the original command again. Alternatively, you can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation. Hint: try $ pipenv lock --pre if it is a pre-release dependency. ERROR: ERROR: Could not find a version that matches pandas No versions found Was https://pypi.org/simple reachable?
问题依旧。
pipenv --version pipenv, version 2018.11.26
本身没问题。
pipenv lock --verbose
结果:
pipenv lock --verbose Locking [dev-packages] dependencies… Locking [packages] dependencies… ✘ Locking Failed! Using pip: -i https://pypi.org/simple Using pip: -i https://pypi.org/simple Using pip: -i https://pypi.org/simple ROUND 1 Current constraints: pandas Finding the best candidates: Traceback (most recent call last): File "/Users/crifan/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pipenv/utils.py", line 385, in resolve results = self.resolver.resolve(max_rounds=environments.PIPENV_MAX_ROUNDS) File "/Users/crifan/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pipenv/patched/piptools/resolver.py", line 102, in resolve has_changed, best_matches = self._resolve_one_round() File "/Users/crifan/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pipenv/patched/piptools/resolver.py", line 198, in _resolve_one_round best_matches = {self.get_best_match(ireq) for ireq in constraints} File "/Users/crifan/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pipenv/patched/piptools/resolver.py", line 198, in <setcomp> best_matches = {self.get_best_match(ireq) for ireq in constraints} File "/Users/crifan/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pipenv/patched/piptools/resolver.py", line 263, in get_best_match best_match = self.repository.find_best_match(ireq, prereleases=self.prereleases) File "/Users/crifan/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pipenv/patched/piptools/repositories/pypi.py", line 175, in find_best_match raise NoCandidateFound(ireq, all_candidates, self.finder) pipenv.patched.piptools.exceptions.NoCandidateFound: Could not find a version that matches pandas No versions found Was https://pypi.org/simple reachable? 。。。
NoCandidateFound
难道是python 3.7 64bit 中没有合适匹配的pandas?
NoCandidateFound
Requires: Python >=3.7.1
我此处是3.7.3,满足要求
算了,去用pyenv给本地Mac中安装最新版Python 3.9试试:
【已解决】Mac中用pyenv安装最新版Python 3.9.4
然后:
【已解决】Mac中pyenv升级了Python版本后找不到pipenv
然后再去试试
pipenv install pandas Installing pandas... Error: An error occurred while installing pandas! Error text: Could not fetch URL https://pypi.org/simple/pandas/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pandas/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available. WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pandas/ WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pandas/ WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pandas/ WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pandas/ WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pandas/ ERROR: Could not find a version that satisfies the requirement pandas (from -r /var/folders/46/2hjxz38n22n3ypp_5f6_p__00000gn/T/pipenv-sgnl0_i3-requirements/pipenv-5yoz6d0_-requirement.txt (line 1)) (from versions: none) ERROR: No matching distribution found for pandas (from -r /var/folders/46/2hjxz38n22n3ypp_5f6_p__00000gn/T/pipenv-sgnl0_i3-requirements/pipenv-5yoz6d0_-requirement.txt (line 1)) ✘ Installation Failed ✘ crifan@licrifandeMacBook-Pro ~/dev/dev_root/projects/团队业绩统计/TeamSaleStatistic
重新启动一个新的终端再去试试

pipenv install pandas Creating a virtualenv for this project... Pipfile: /Users/crifan/dev/dev_root/projects/团队业绩统计/Pipfile Using /Users/crifan/.pyenv/versions/3.9.4/bin/python3 (3.9.4) to create virtualenv... ⠴ Creating virtual environment...created virtual environment CPython3.9.4.final.0-64 in 2484ms creator CPython3Posix(dest=/Users/crifan/.local/share/virtualenvs/团队业绩统计-kPDZnDMg, clear=False, no_vcs_ignore=False, global=False) seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/Users/crifan/Library/Application Support/virtualenv) added seed packages: pip==21.1.2, setuptools==57.0.0, wheel==0.36.2 activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator ✔ Successfully created virtual environment! Virtualenv location: /Users/crifan/.local/share/virtualenvs/团队业绩统计-kPDZnDMg Creating a Pipfile for this project... Installing pandas... ⠏ Installing pandas...

安装很慢,等了好一会,还是没进展
过了还一会,终于安装完毕了:
Installing pandas... Adding pandas to Pipfile's [packages]... ✔ Installation Succeeded Pipfile.lock not found, creating... Locking [dev-packages] dependencies... Locking [packages] dependencies... Building requirements... Resolving dependencies... ✔ Success! Updated Pipfile.lock (1b8c22)! Installing dependencies from Pipfile.lock (1b8c22)... 🐍 ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 0/0 — 00:00:00 To activate this project's virtualenv, run pipenv shell. Alternatively, run a command inside the virtualenv with pipenv run.
locking也是花了很久。
pipenv graph pandas==1.2.4 - numpy [required: >=1.16.5, installed: 1.20.3] - python-dateutil [required: >=2.7.3, installed: 2.8.1] - six [required: >=1.5, installed: 1.16.0] - pytz [required: >=2017.3, installed: 2021.1]
即可。
后记:
路径搞错了,所以去删除掉,重新创建:
✘ crifan@licrifandeMacBook-Pro ~/dev/dev_root/projects/团队业绩统计/TeamSaleStatistic pipenv --rm Removing virtualenv (/Users/crifan/.local/share/virtualenvs/TeamSaleStatistic-VIYlkgMt)... crifan@licrifandeMacBook-Pro ~/dev/dev_root/projects/团队业绩统计/TeamSaleStatistic pipenv install pandas Creating a virtualenv for this project... Pipfile: /Users/crifan/dev/dev_root/projects/团队业绩统计/TeamSaleStatistic/Pipfile Using /Users/crifan/.pyenv/versions/3.9.4/bin/python3 (3.9.4) to create virtualenv... ⠹ Creating virtual environment...created virtual environment CPython3.9.4.final.0-64 in 661ms creator CPython3Posix(dest=/Users/crifan/.local/share/virtualenvs/TeamSaleStatistic-VIYlkgMt, clear=False, no_vcs_ignore=False, global=False) seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/Users/crifan/Library/Application Support/virtualenv) added seed packages: pip==21.1.2, setuptools==57.0.0, wheel==0.36.2 activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator ✔ Successfully created virtual environment! Virtualenv location: /Users/crifan/.local/share/virtualenvs/TeamSaleStatistic-VIYlkgMt Creating a Pipfile for this project... Installing pandas... Adding pandas to Pipfile's [packages]... ✔ Installation Succeeded Pipfile.lock not found, creating... Locking [dev-packages] dependencies... Locking [packages] dependencies... Building requirements... Resolving dependencies... ✔ Success! Updated Pipfile.lock (1b8c22)! Installing dependencies from Pipfile.lock (1b8c22)... 🐍 ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 0/0 — 00:00:00 To activate this project's virtualenv, run pipenv shell. Alternatively, run a command inside the virtualenv with pipenv run.
【总结】
此处之前用python 3.7.3,去:
pipenv install pandas
结果报错
pipenv.exceptions.ResolutionFailure: ERROR: ERROR: Could not find a version that matches pandas
原因:估计是 3.7.3的Python中没有合适的pandas的版本
解决办法:换最新Python,比如此处的3.9.4,然后再去用
pipenv install pandas
就可以了。
转载请注明:在路上 » 【已解决】Mac中pipenv安装报错:Could not find a version that matches pandas