Home>

Create a virtual environment using pipenv, that's it ...

What you did, error message

When I ran the first line of code on the command prompt, I got the following message:
The same thing happens with or without pipfile in the directory.

C: \ Users \ namae \ OneDrive \ Document>pipenv install
Creating a virtualenv for this project…
Pipfile: C: \ Users \ namae \ OneDrive \ Document \ Pipfile
Using C: /Users/namae/AppData/Local/Programs/Python/Python38/python.exe (3.8.4) to create virtualenv…
[===] Creating virtual environment ... created virtual environment CPython3.8.4.final.0-64 in 1729ms
  creator CPython3Windows (dest = C: \ Users \ namae \ .virtualenvs \ Document-93FUvPFU, clear = False, global = False)
  seeder FromAppData (download = False, pip = bundle, setuptools = bundle, wheel = bundle, via = copy, app_data_dir = C: \ Users \ namae \ AppData \ Local \ pypa \ virtualenv)
    added seed packages: pip == 20.2.2, setuptools == 49.6.0, wheel == 0.35.1
  activators BashActivator, BatchActivator, FishActivator, PowerShellActivator, PythonActivator, XonshActivator
Successfully created virtual environment!
Virtualenv location: C: \ Users \ namae \ .virtualenvs \ Document-93FUvPFU
Creating a Pipfile for this project…
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
Updated Pipfile.lock (1f10f9)!
Traceback (most recent call last):
  File "c: \ users \ namae \ appdata \ local \ programs \ python \ python38 \ lib \ runpy.py", line 194, in _run_module_as_main
    return _run_code (code, main_globals, None, None,
  File "c: \ users \ namae \ appdata \ local \ programs \ python \ python38 \ lib \ runpy.py", line 87, in _run_code
    exec (code, run_globals)
  File "C: \ Users \ namae \ AppData \ Local \ Programs \ Python \ Python38 \ Scripts \ pipenv.exe \ __main__.py", line 7, in<module>
  File "C: \ Users \ namae \ AppData \ Local \ Programs \ Python \ Python38 \ Lib \ site-packages \ pipenv \ vendor \ click \ core.py", line 829, in __call__
    return self.main (* args, ** kwargs)
  File "C: \ Users \ namae \ AppData \ Local \ Programs \ Python \ Python38 \ Lib \ site-packages \ pipenv \ vendor \ click \ core.py", line 782, in main
    rv = self.invoke (ctx)
(Omitted)
  File "c: \ users \ namae \ appdata \ local \ programs \ python \ python38 \ lib \ site-packages \ pipenv \ project.py", line 796, in get_or_create_lockfile
    if self.lockfile_exists and self.lockfile_content:
  File "c: \ users \ namae \ appdata \ local \ programs \ python \ python38 \ lib \ site-packages \ pipenv \ project.py", line 662, in lockfile_content
    return self.load_lockfile ()
  File "c: \ users \ namae \ appdata \ local \ programs \ python \ python38 \ lib \ site-packages \ pipenv \ project.py", line 1054, in load_lockfile
    j ["_ meta"] ["sources"] [i] ["url"]
KeyError:'url'
Generated pipfile
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
[packages]
[requires]
python_version = "3.8"
Generated pipfile.lock
{
"_meta": {
"hash": {
"sha256": "c2384ad47b0fded84aa8d567ff10e9e32bb6e8da4cb9d05c0b5403e63a1f10f9"
},
"pipfile-spec": 6,
"requires": {},
"sources": [
{}
]
},
"default": {},
"develop": {}
}

I have no idea what to do if I look it up ...

environment

Windows10 home

  • Answer # 1

    I didn't know the root cause, but the generated pipfile.lock

    {
    "_meta": {
    "hash": {
    "sha256": "c2384ad47b0fded84aa8d567ff10e9e32bb6e8da4cb9d05c0b5403e63a1f10f9"
    },
    "pipfile-spec": 6,
    "requires": {},
    "sources": [
    {}
    ]
    },
    "default": {},
    "develop": {}
    }


    In

    "sources": [
    {}
    ]


    To
    "sources": []
    After changing topipenv install(perhapspipenv sync(Maybe it was), and the empty environment was successfully built.

    In other words

    {
    "_meta": {
    "hash": {
    "sha256": "c2384ad47b0fded84aa8d567ff10e9e32bb6e8da4cb9d05c0b5403e63a1f10f9"
    },
    "pipfile-spec": 6,
    "requires": {},
    "sources": []
    },
    "default": {},
    "develop": {}
    }


    about it.

  • Answer # 2

    Try it out in a clean folder in your environmentpipenv installI just tried it
    Presented in the commentsPipfile.lockIt seems that the contents are different.

    Pipfile.lockI feel that the necessary information is not output at the time of generation, so
    one timePipfile.lockYou may want to try removing.

    Confirmation environment

    OS: Arch Linux, Windows 10

    Python: 3.8.5

    Pipenv: 2020.8.13

    Output file contents

    * Preparepipenv installCheck each file immediately after executing

    Pipfile

    [[source]]
    name = "pypi"
    url = "https://pypi.org/simple"
    verify_ssl = true
    [dev-packages]
    [packages]
    [requires]
    python_version = "3.8"

    Pipfile.lock

    {
        "_meta": {
            "hash": {
                "sha256": "7f7606f08e0544d8d012ef4d097dabdd6df6843a28793eb6551245d4b2db4242"
            },
            "pipfile-spec": 6,
            "requires": {
                "python_version": "3.8"
            },
            "sources": [
                {
                    "name": "pypi",
                    "url": "https://pypi.org/simple",
                    "verify_ssl": true
                }
            ]
        },
        "default": {},
        "develop": {}
    }