首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在OSX Mojave上使用pip会迫使我安装最近发布的python包。

在OSX Mojave上使用pip会迫使我安装最近发布的python包。
EN

Stack Overflow用户
提问于 2020-04-02 21:07:27
回答 1查看 189关注 0票数 0

因此,我最近更新了一台旧的macbook pro到Mojave (osx 10.14),并决定将其作为辅助笔记本电脑进行开发。使用python 3.7,我创建了一个虚拟环境,如下所示:

代码语言:javascript
复制
python3.7 -m venv myvirtualenv

获取我正在处理的存储库,启用我的virtualenv并开始安装需求:

代码语言:javascript
复制
billiard==3.6.1.0
boto3==1.9.248
botocore==1.12.248
celery==4.3.0
certifi==2018.8.24
chardet==3.0.4
defusedxml==0.5.0
dj-database-url==0.5.0
Django==2.2
django-appconf==1.0.3
django-autoslug==1.9.6
django-celery==3.3.1
django-cors-headers==3.1.0
django-heroku==0.3.1
django-mailing==0.1.3
django-storages==1.7.2
django-otp==0.5.0
django-redis-cache==2.1.0
django-templated-mail==1.1.1
djangorestframework==3.8.2
djangorestframework-jwt==1.11.0
djoser==1.7.0
docutils==0.15.2
idna==2.7
importlib-metadata==0.23
jmespath==0.9.4
kombu==4.6.5
more-itertools==7.2.0
oauthlib==2.1.0
Pillow==6.2.0
psycopg2==2.8.3
PyJWT==1.6.4
python-dateutil==2.8.0
python-http-client==3.2.1
python3-openid==3.1.0
pytz==2018.5
redis==3.3.8
requests==2.19.1
requests-oauthlib==1.0.0
rest-social-auth==1.4.0
s3transfer==0.2.1
sendgrid==6.1.0
six==1.11.0
social-auth-app-django==2.1.0
social-auth-core==1.7.0
sqlparse==0.3.0
urllib3==1.23
vine==1.3.0
gunicorn==19.9.0
whitenoise==4.1.4
zipp==0.6.0
django-celery-beat==1.5.0

问题是,pip拒绝安装这个版本,并强迫我使用更新的包。例如,我不能安装Django 2.2.12 (只有3.0.5和更高版本):

代码语言:javascript
复制
    pip install django==2.2.12
    Looking in indexes: https://pypi.python.org/pypi/
    Collecting django==2.2.12
      ERROR: Could not find a version that satisfies the requirement django==2.2.12 **(from versions: 3.0.5)**
    ERROR: No matching distribution found for django==2.2.12

对于我的需求,几乎所有的包都是一样的。

我测试了几个python版本(从3.4到3.8)和几个pip版本(从10到20,下载get-pi.py脚本并运行它)。我非常确定我在创建的每个venv上都使用了正确的python和pip版本。以上所有功能在过时的el capitan macbook上都能完美工作,所以我感觉到OSX有个问题。Pip详细日志为(pip 20.0.2):

代码语言:javascript
复制
  pip install -vvv django==2.2.12
    Non-user install because user site-packages disabled
    Created temporary directory: /private/var/folders/dp/lsdfffdx6b19vw5ykvwwyf280000gn/T/pip-ephem-wheel-cache-ouaeti4l
    Created temporary directory: /private/var/folders/dp/lsdfffdx6b19vw5ykvwwyf280000gn/T/pip-req-tracker-3hfud6vs
    Initialized build tracking at /private/var/folders/dp/lsdfffdx6b19vw5ykvwwyf280000gn/T/pip-req-tracker-3hfud6vs
    Created build tracker: /private/var/folders/dp/lsdfffdx6b19vw5ykvwwyf280000gn/T/pip-req-tracker-3hfud6vs
    Entered build tracker: /private/var/folders/dp/lsdfffdx6b19vw5ykvwwyf280000gn/T/pip-req-tracker-3hfud6vs
    Created temporary directory: /private/var/folders/dp/lsdfffdx6b19vw5ykvwwyf280000gn/T/pip-install-s86u8lbh
    Looking in indexes: https://pypi.python.org/pypi/
    1 location(s) to search for versions of django:
    * https://pypi.python.org/pypi/django/
    Fetching project page and analyzing links: https://pypi.python.org/pypi/django/
    Getting page https://pypi.python.org/pypi/django/
    Found index url https://pypi.python.org/pypi/
    Starting new HTTPS connection (1): pypi.python.org:443
    https://pypi.python.org:443 "GET /pypi/django/ HTTP/1.1" 301 122
    Starting new HTTPS connection (1): pypi.org:443
    https://pypi.org:443 "GET /pypi/django/ HTTP/1.1" 301 213
    https://pypi.org:443 "GET /project/django/ HTTP/1.1" 301 213
    https://pypi.org:443 "GET /project/Django/ HTTP/1.1" 200 14886
      Skipping link: not a file: https://pypi.org/project/Django/#content (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://pypi.org/ (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://pypi.org/help/ (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://donate.pypi.org (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://pypi.org/account/login/ (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://pypi.org/account/register/ (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://pypi.org/project/Django/ (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://pypi.org/project/Django/#description (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://pypi.org/project/Django/#history (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://pypi.org/project/Django/#files (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://www.djangoproject.com/ (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://code.djangoproject.com/ (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://github.com/django/django (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://www.djangoproject.com/fundraising/ (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://docs.djangoproject.com/ (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://libraries.io/pypi/Django (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://packaging.python.org/guides/analyzing-pypi-package-downloads/ (from https://pypi.org/project/Django/)
      Skipping link: unsupported archive format: .com: mailto:foundation%40djangoproject.com (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://pypi.org/user/apollo13/ (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://pypi.org/user/carltongibson/ (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://pypi.org/user/felixx/ (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://pypi.org/user/jacobian/ (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://pypi.org/user/ubernostrum/ (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://pypi.org/search/?c=Development+Status+%3A%3A+5+-+Production%2FStable (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://pypi.org/search/?c=Environment+%3A%3A+Web+Environment (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://pypi.org/search/?c=Framework+%3A%3A+Django (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://pypi.org/search/?c=Intended+Audience+%3A%3A+Developers (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://pypi.org/search/?c=License+%3A%3A+OSI+Approved+%3A%3A+BSD+License (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://pypi.org/search/?c=Operating+System+%3A%3A+OS+Independent (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://pypi.org/search/?c=Programming+Language+%3A%3A+Python (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://pypi.org/search/?c=Programming+Language+%3A%3A+Python+%3A%3A+3 (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://pypi.org/search/?c=Programming+Language+%3A%3A+Python+%3A%3A+3+%3A%3A+Only (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://pypi.org/search/?c=Programming+Language+%3A%3A+Python+%3A%3A+3.6 (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://pypi.org/search/?c=Programming+Language+%3A%3A+Python+%3A%3A+3.7 (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://pypi.org/search/?c=Programming+Language+%3A%3A+Python+%3A%3A+3.8 (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://pypi.org/search/?c=Topic+%3A%3A+Internet+%3A%3A+WWW%2FHTTP (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://pypi.org/search/?c=Topic+%3A%3A+Internet+%3A%3A+WWW%2FHTTP+%3A%3A+Dynamic+Content (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://pypi.org/search/?c=Topic+%3A%3A+Internet+%3A%3A+WWW%2FHTTP+%3A%3A+WSGI (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://pypi.org/search/?c=Topic+%3A%3A+Software+Development+%3A%3A+Libraries+%3A%3A+Application+Frameworks (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://pypi.org/search/?c=Topic+%3A%3A+Software+Development+%3A%3A+Libraries+%3A%3A+Python+Modules (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://pypi.org/project/Django/#data (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://docs.djangoproject.com/en/stable/ (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://code.djangoproject.com/newticket (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://en.wikipedia.org/wiki/Wikipedia%3AIRC/Tutorial (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://groups.google.com/group/django-users (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://docs.djangoproject.com/en/dev/internals/contributing/ (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/unit-tests/#running-the-unit-tests (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://pypi.org/help/#project-release-notifications (from https://pypi.org/project/Django/)
      Skipping link: unsupported archive format: .5: https://pypi.org/project/Django/3.0.5/ (from https://pypi.org/project/Django/)
      Skipping link: unsupported archive format: .13: https://pypi.org/project/Django/2.0.13/ (from https://pypi.org/project/Django/)
      Skipping link: unsupported archive format: .12: https://pypi.org/project/Django/2.0.12/ (from https://pypi.org/project/Django/)

      Skipping link: not a file: https://packaging.python.org/installing/ (from https://pypi.org/project/Django/)
      Found link https://files.pythonhosted.org/packages/a9/4f/8a247eee2958529a6a805d38fbacd9764fd566462fa0016aa2a2947ab2a6/Django-3.0.5-py3-none-any.whl (from https://pypi.org/project/Django/), version: 3.0.5
      Skipping link: not a file: https://pypi.org/project/Django/#copy-hash-modal-b9735743-a7e7-4ab4-95f0-c6f4582855ff (from https://pypi.org/project/Django/)
      Found link https://files.pythonhosted.org/packages/ed/52/1f281f39fe38d10c6c73e1c1d26a0aad5406be1108bf5f50423751ea8aa3/Django-3.0.5.tar.gz (from https://pypi.org/project/Django/), version: 3.0.5
      Skipping link: not a file: https://pypi.org/project/Django/#copy-hash-modal-e74730bd-b9a1-4d5a-aa25-3f2ee7cd20c3 (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://pypi.org/project/Django/#modal-close (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://pip.pypa.io/en/stable/reference/pip_install/#hash-checking-mode (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://packaging.python.org/tutorials/packaging-projects/ (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://packaging.python.org/ (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://twitter.com/PyPI (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://dtdg.co/pypi (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://www.python.org/dev/peps/pep-0541/ (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://pypi.org/sponsors/ (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://pypi.org/help/#feedback (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://github.com/pypa/warehouse (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://hosted.weblate.org/projects/pypa/warehouse/ (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://github.com/pypa/warehouse/graphs/contributors (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://www.pypa.io/en/latest/code-of-conduct/ (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://pypi.org/security/ (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://www.python.org/privacy/ (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://pypi.org/policy/terms-of-use/ (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://status.python.org/ (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://www.python.org/psf/ (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://pypi.org/sitemap/ (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://www.pingdom.com/ (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://cloud.google.com/ (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://getsentry.com/for/python (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://aws.amazon.com/ (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://www.datadoghq.com/ (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://www.fastly.com/ (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://www.digicert.com/ (from https://pypi.org/project/Django/)
      Skipping link: not a file: https://statuspage.io (from https://pypi.org/project/Django/)
    Given no hashes to check 0 links for project 'django': discarding no candidates
    ERROR: Could not find a version that satisfies the requirement django==2.2.12 (from versions: 3.0.5)
    Cleaning up...
    Removed build tracker: '/private/var/folders/dp/lsdfffdx6b19vw5ykvwwyf280000gn/T/pip-req-tracker-3hfud6vs'
    ERROR: No matching distribution found for django==2.2.12
    Exception information:
    Traceback (most recent call last):
      File "/pathtovirtualenv/lib/python3.7/site-packages/pip/_internal/cli/base_command.py", line 186, in _main
        status = self.run(options, args)
      File "/pathtovirtualenv/lib/python3.7/site-packages/pip/_internal/commands/install.py", line 331, in run
        resolver.resolve(requirement_set)
      File "/pathtovirtualenv/lib/python3.7/site-packages/pip/_internal/legacy_resolve.py", line 177, in resolve
        discovered_reqs.extend(self._resolve_one(requirement_set, req))
      File "/pathtovirtualenv/lib/python3.7/site-packages/pip/_internal/legacy_resolve.py", line 333, in _resolve_one
        abstract_dist = self._get_abstract_dist_for(req_to_install)
      File "/pathtovirtualenv/lib/python3.7/site-packages/pip/_internal/legacy_resolve.py", line 281, in _get_abstract_dist_for
        req.populate_link(self.finder, upgrade_allowed, require_hashes)
      File "/pathtovirtualenv/lib/python3.7/site-packages/pip/_internal/req/req_install.py", line 249, in populate_link
        self.link = finder.find_requirement(self, upgrade)
      File "/pathtovirtualenv/lib/python3.7/site-packages/pip/_internal/index/package_finder.py", line 927, in find_requirement
        'No matching distribution found for %s' % req
    pip._internal.exceptions.DistributionNotFound: No matching distribution found for django==2.2.12
EN

回答 1

Stack Overflow用户

发布于 2020-05-12 20:38:59

经过一些挖掘,我找到了一个对我有效的解决方案,灵感来自于这个无关的答案:Updating the pip.conf file to use https

在我的/Users/USERNAME/.pip/pip.conf上

代码语言:javascript
复制
[global]
index-url=https://pypi.python.org/pypi/
trusted-host = pypi.python.org
               pypi.org
               files.pythonhosted.org

刚刚将index-url更改为:

代码语言:javascript
复制
index-url=https://pypi.python.org/simple/

等着瞧吧!

然而,我不知道我是否在将来需要安装更新版本的pip包时引入了一些问题。我想如果我偶然发现他们,我会把pip.conf恢复为pypi。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60992315

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档