最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【基本解决】pipenv用已有pipfile去创建环境失败:Warning Python 3.6 was not found on your system

Python crifan 10014浏览 0评论

折腾:

【已解决】把Python3的Flask部署到远程CentOS7服务器

期间,已经解决了:

【基本解决】如何利用已有Pipfile和Pipfile.lock创建pipenv的虚拟环境

但是接着又出现:

提示你系统中没有3.6:

<code>[root@naturling-general-01 robotDemo]# pipenv install
Warning: Python 3.6 was not found on your system
You can specify specific versions of Python with:
  $ pipenv --python path/to/python
</code>

->要么是去系统中再安装个3.6的python

-》要么是使用pipenv去使用系统此处的python3.4

pipenv Warning Python 3.6 was not found on your system

Can pipenv find Pythons on Windows? · Issue #580 · pypa/pipenv

pipenv installs 3.6.2 using pyenv, but creates 2.7 env · Issue #700 · pypa/pipenv

pipenv using wrong python with pyenv · Issue #729 · pypa/pipenv

specify patch version of python for installation via pyenv? · Issue #588 · pypa/pipenv

pyenv – Shouldn’t pipenv be able to detect my python 2 installation? – Stack Overflow

pipenv 更优雅的管理你的python开发环境 – 掘金

参考:

<code>pipenv --help
</code>

中的:

Usage Examples:

   Create a new project using Python 3.6, specifically:

   $ pipenv –python 3.6

去试试

<code>[root@naturling-general-01 robotDemo]# pipenv install --python 3.6
Warning: Python 3.6 was not found on your system
You can specify specific versions of Python with:
  $ pipenv --python path/to/python
</code>

换成3.4:

<code>[root@naturling-general-01 robotDemo]# pipenv install --python 3.4
Creating a virtualenv for this project[39m
Using /usr/bin/python3.4m (3.4.5) to create virtualenv[39m
[34mRunning virtualenv with interpreter /usr/bin/python3.4m
Using base prefix '/usr'
New python executable in /root/.local/share/virtualenvs/robotDemo-dwdcgdaG/bin/python3.4m
Also creating executable in /root/.local/share/virtualenvs/robotDemo-dwdcgdaG/bin/python
Please make sure you remove any previous custom paths from your /root/.pydistutils.cfg file.
Installing setuptools, pip, wheel...done.

Virtualenv location: /root/.local/share/virtualenvs/robotDemo-dwdcgdaG
Warning: Your Pipfile requires python_version 3.6, but you are using 3.4.5 (/root/.local/share/v/r/bin/python).
  $ pipenv check will surely fail.
Installing dependencies from Pipfile.lock (cdbe9e)[39m
     [39m[39m[39m[39m[39m[39m[39m[39m[39m[39m[39m[39m[39m[39m[39m[39m[39m[39m[39m[39m[39m[39m[39m[39m[39m[39m[39m[39m[39m[39m[39m[39m 13/13 [30m00:00:22
To activate this project's virtualenv, run the following:
 $ pipenv shell
</code>

是可以去安装的,但是提示你后续check会出错而已。

先暂时这么用吧。

去看看配置:

<code>[root@naturling-general-01 robotDemo]# cat Pipfile
[[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"

[packages]
flask = "*"
flask-restful = "*"
flask-pymongo = "*"
gunicorn = "*"

[dev-packages]

[requires]
python_version = "3.6"
[root@naturling-general-01 robotDemo]# cat Pipfile.lock 
{
    "_meta": {
        "hash": {
            "sha256": "925163cb94ee3e4dd93b88390977daad4361ed7471144048e07659d6cdcdbe9e"
        },
        "pipfile-spec": 6,
        "requires": {
            "python_version": "3.6"
        },
        "sources": [
            {
                "name": "pypi",
                "url": "https://pypi.python.org/simple",
                "verify_ssl": true
            }
        ]
    },
    "default": {
        "aniso8601": {
            "hashes": [
                "sha256:7cf068e7aec00edeb21879c2bbda048656c34d281e133a77425be03b352122d8",
                "sha256:f7052eb342bf2000c6264a253acedb362513bf9270800be2bc8e3e229fe08b5a"
            ],
            "version": "==3.0.0"
        },
        "click": {
            "hashes": [
                "sha256:29f99fc6125fbc931b758dc053b3114e55c77a6e4c6c3a2674a2dc986016381d",
                "sha256:f15516df478d5a56180fbf80e68f206010e6d160fc39fa508b65e035fd75130b"
            ],
            "version": "==6.7"
        },
        "flask": {
            "hashes": [
                "sha256:0749df235e3ff61ac108f69ac178c9770caeaccad2509cb762ce1f65570a8856",
                "sha256:49f44461237b69ecd901cc7ce66feea0319b9158743dd27a2899962ab214dac1"
            ],
            "index": "pypi",
            "version": "==0.12.2"
        },
        "flask-pymongo": {
            "hashes": [
                "sha256:0d3cb35f874e17cc0f08066936e2f96a7a65e65af00609211b3e7518bf499813",
                "sha256:2baaa2ba5107d72b3a8bd4b5c0c8881316e35340ad1ae979cc13f1f3c8843b3d",
                "sha256:e81c2001be555e255b3ac7776f0f2f5921f6aeef9fc94edb47c1fca2b532e59c"
            ],
            "index": "pypi",
            "version": "==0.5.1"
        },
        "flask-restful": {
            "hashes": [
                "sha256:5795519501347e108c436b693ff9a4d7b373a3ac9069627d64e4001c05dd3407",
                "sha256:e2f1b8063de3944b94c7f8be5cee4d2161db0267c54c5b757d875295061776fa"
            ],
            "index": "pypi",
            "version": "==0.3.6"
        },
        "gunicorn": {
            "hashes": [
                "sha256:75af03c99389535f218cc596c7de74df4763803f7b63eb09d77e92b3956b36c6",
                "sha256:eee1169f0ca667be05db3351a0960765620dad53f53434262ff8901b68a1b622"
            ],
            "index": "pypi",
            "version": "==19.7.1"
        },
        "itsdangerous": {
            "hashes": [
                "sha256:cbb3fcf8d3e33df861709ecaf89d9e6629cff0a217bc2848f1b41cd30d360519"
            ],
            "version": "==0.24"
        },
        "jinja2": {
            "hashes": [
                "sha256:74c935a1b8bb9a3947c50a54766a969d4846290e1e788ea44c1392163723c3bd",
                "sha256:f84be1bb0040caca4cea721fcbbbbd61f9be9464ca236387158b0feea01914a4"
            ],
            "version": "==2.10"
        },
        "markupsafe": {
            "hashes": [
                "sha256:a6be69091dac236ea9c6bc7d012beab42010fa914c459791d627dad4910eb665"
            ],
            "version": "==1.0"
        },
        "pymongo": {
            "hashes": [
                "sha256:051770590ddbd5fb7db17d3315d4c1b0f18039d830dd18e1bae39451c30d31cd",
...
                "sha256:f7ebcb846962ee40374db2d9014a89bea9c983ae63c1877957c3a0a756974796"
            ],
            "version": "==3.6.1"
        },
        "pytz": {
            "hashes": [
                "sha256:65ae0c8101309c45772196b21b74c46b2e5d11b6275c45d251b150d5da334555",
                "sha256:c06425302f2cf668f1bba7a0a03f3c1d34d4ebeef2c72003da308b3947c7f749"
            ],
            "version": "==2018.4"
        },
        "six": {
            "hashes": [
                "sha256:70e8a77beed4562e7f14fe23a786b54f6296e34344c23bc42f07b15018ff98e9",
                "sha256:832dc0e10feb1aa2c68dcc57dbb658f1c7e65b9b61af69048abc87a2db00a0eb"
            ],
            "version": "==1.11.0"
        },
        "werkzeug": {
            "hashes": [
                "sha256:c3fd7a7d41976d9f44db327260e263132466836cef6f91512889ed60ad26557c",
                "sha256:d5da73735293558eb1651ee2fddc4d0dedcfa06538b8813a2e20011583c9e49b"
            ],
            "version": "==0.14.1"
        }
    },
    "develop": {}
}
</code>

【总结】

此处去使用

之前在Mac本地的:

<code>➜  robotDemo which python
/usr/bin/python
➜  robotDemo python --version
Python 2.7.10
➜  robotDemo pipenv shell
Spawning environment shell (/bin/zsh). Use 'exit' to leave.
. /Users/crifan/.local/share/virtualenvs/robotDemo-HXjMJQEQ/bin/activate
➜  robotDemo . /Users/crifan/.local/share/virtualenvs/robotDemo-HXjMJQEQ/bin/activate
➜  robotDemo which python
/Users/crifan/.local/share/virtualenvs/robotDemo-HXjMJQEQ/bin/python
➜  robotDemo python --version
Python 3.6.4
</code>

所生成的Pipfile中以来的python是3.6的:

<code>[requires]
python_version = "3.6"
</code>

而想要将整个环境部署到远程CentOS服务器中,但是:

服务器中安装好的Python3是3.4的:

<code>[root@naturling-general-01 robotDemo]# which python
/usr/bin/python
[root@naturling-general-01 robotDemo]# python --version
Python 2.7.5
[root@naturling-general-01 robotDemo]# which python3
/usr/bin/python3
[root@naturling-general-01 robotDemo]# python3 --version
Python 3.4.5
[root@naturling-general-01 robotDemo]# 
[root@naturling-general-01 robotDemo]# pipenv shell
Warning: Your Pipfile requires python_version 3.6, but you are using 3.4.5 (/root/.local/share/v/r/bin/python).
  $ pipenv check will surely fail.
Spawning environment shell (/bin/bash). Use 'exit' to leave.
[root@naturling-general-01 robotDemo]# . /root/.local/share/virtualenvs/robotDemo-dwdcgdaG/bin/activate
(robotDemo-dwdcgdaG) [root@naturling-general-01 robotDemo]# which python
/root/.local/share/virtualenvs/robotDemo-dwdcgdaG/bin/python
(robotDemo-dwdcgdaG) [root@naturling-general-01 robotDemo]# python --version
Python 3.4.5
(robotDemo-dwdcgdaG) [root@naturling-general-01 robotDemo]# exit
exit
</code>

所以服务器中没有安装,Pipfile所希望的3.6的Python,导致去新建环境时出错:

Warning Python 3.6 was not found on your system

而解决办法是:

没法完美的实现两个虚拟环境的一致

又不想去:

  • 要么重新安装Mac本地的Python3为Python 3.4,重新弄出pipenv的环境

  • 要么重新安装服务器中的Python3为Python 3.6,这样就和本地Mac的Pipfile一致了

而考虑到,目前Python3(Flask的)代码不是很多,Python3.4和Python3.6差异不是很大,至少短期内用起来没有问题,所以先:

将就着,在服务器端,使用本地Mac中的Python3.6的Pipfile,但是创建出来的虚拟环境时3.4的

步骤:

先把Mac的Python3.6的Pipfile和Pipfile.lock上传到服务器中对应文件夹下,再去

<code>pipenv install --python 3.4
</code>

即可。

此时:

服务器中pipenv虚拟环境中安装的Python是服务器的3.4的Python。

但是Pipfile中还是写的:

<code>[requires]
python_version = "3.6"
</code>

先这么着吧。

转载请注明:在路上 » 【基本解决】pipenv用已有pipfile去创建环境失败:Warning Python 3.6 was not found on your system

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
82 queries in 0.165 seconds, using 22.17MB memory