pipenv安裝庫使用國內鏡像


pipenv install django超級慢,卡住不動,最后不得不CTRL+C中止

時有必要改成國內源了,打開Pipfile文件,發現內容是:

[[source]]
verify_ssl = true
name = "pypi" url = "https://pypi.org/simple"

[packages]


[dev-packages]

[requires]
python_version = "3.4"

把url替換成阿里雲源(這里國內源的選擇問題可以參考我上篇文章:《pip使用國內鏡像解決安裝超時):http://mirrors.aliyun.com/pypi/simple/     

運行發現有出現不信任的問題了

索性將url改成url = "http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com"

[[source]]
verify_ssl = true
name = "pypi"
url = "http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com" 
[packages]


[dev-packages]

[requires]
python_version = "3.4"

再次安裝,顯示:

這個問題是由於django需要python版本大於等於3.5,我的是3.4.4,版本不匹配導致,換requests庫試試:pipenv install requests

可以看到,只花了3s,速度感人,有人說,清華源更好用,豆瓣源不好用,還沒嘗試

需要注意的是,這時候Profile文件中的[packages]下,多了requests = "*",標識了本項目依賴於requests

[[source]]
verify_ssl = true
name = "pypi"
url = "http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com"

[packages]
requests = "*" 
[dev-packages]

[requires]
python_version = "3.4"

同時安裝過程中有句話叫做 Updated Pipfile.lock,這時我們可以發現項目路徑下又生成了一個 Pipfile.lock 文件,內容如下:

{
    "_meta": {
        "hash": {
            "sha256": "2520a3c6b3ead035956ec3f7f1a9ebeb0c274f4e1568f752dcfd4d6538193c52"
        },
        "pipfile-spec": 6,
        "requires": {
            "python_version": "3.4"
        },
        "sources": [
            {
                "name": "pypi",
                "url": "http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com",
                "verify_ssl": true
            }
        ]
    },
    "default": {
        "certifi": {
            "hashes": [
                "sha256:376690d6f16d32f9d1fe8932551d80b23e9d393a8578c5633a2ed39a64861638",
                "sha256:456048c7e371c089d0a77a5212fb37a2c2dce1e24146e3b7e0261736aaeaa22a"
            ],
            "version": "==2018.8.24"
        },
        "chardet": {
            "hashes": [
                "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae",
                "sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691"
            ],
            "version": "==3.0.4"
        },
        "idna": {
            "hashes": [
                "sha256:156a6814fb5ac1fc6850fb002e0852d56c0c8d2531923a51032d1b70760e186e",
                "sha256:684a38a6f903c1d71d6d5fac066b58d7768af4de2b832e426ec79c30daa94a16"
            ],
            "version": "==2.7"
        },
        "requests": {
            "hashes": [
                "sha256:63b52e3c866428a224f97cab011de738c36aec0185aa91cfacd418b5d58911d1",
                "sha256:ec22d826a36ed72a7358ff3fe56cbd4ba69dd7a6718ffd450ff0e9df7a47ce6a"
            ],
            "index": "pypi",
            "version": "==2.19.1"
        },
        "urllib3": {
            "hashes": [
                "sha256:a68ac5e15e76e7e5dd2b8f94007233e01effe3e50e8daddf69acfd81cb686baf",
                "sha256:b5725a0bd4ba422ab0e66e89e030c806576753ea3ee08554382c14e685d117b5"
            ],
            "markers": "python_version != '3.2.*' and python_version < '4' and python_version != '3.1.*' and python_version != '3.3.*' and python_version != '3.0.*' and python_version >= '2.6'",
            "version": "==1.23"
        }
    },
    "develop": {}
}

可以看到里面標識了 Python 環境基本信息,以及依賴包的版本及 hashes 值

 

 

參考文章

https://blog.csdn.net/jpch89/article/details/81952416

https://cuiqingcai.com/5846.html

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM