Skip to content

ValueError: invalid literal for int() with base 10 when running a script as .\ex.py #4368

Description

@pfmoore

Issue description

Running pipenv run .\ex.py fails with a long traceback, whereas pipenv run ex.py works.

Expected result

Including the directory name should make no difference.

Actual result

>py -m pipenv run .\ex.py
Traceback (most recent call last):
  File "C:\Users\Gustav\AppData\Roaming\Python\Python38\site-packages\pipenv\core.py", line 1636, in system_which
    assert c.return_code == 0
AssertionError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Gustav\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\Gustav\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\Gustav\AppData\Roaming\Python\Python38\site-packages\pipenv\__main__.py", line 5, in <module>
    cli()
  File "C:\Users\Gustav\AppData\Roaming\Python\Python38\site-packages\pipenv\vendor\click\core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\Gustav\AppData\Roaming\Python\Python38\site-packages\pipenv\vendor\click\core.py", line 782, in main
    rv = self.invoke(ctx)
  File "C:\Users\Gustav\AppData\Roaming\Python\Python38\site-packages\pipenv\vendor\click\core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\Gustav\AppData\Roaming\Python\Python38\site-packages\pipenv\vendor\click\core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\Gustav\AppData\Roaming\Python\Python38\site-packages\pipenv\vendor\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "C:\Users\Gustav\AppData\Roaming\Python\Python38\site-packages\pipenv\vendor\click\decorators.py", line 73, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "C:\Users\Gustav\AppData\Roaming\Python\Python38\site-packages\pipenv\vendor\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "C:\Users\Gustav\AppData\Roaming\Python\Python38\site-packages\pipenv\cli\command.py", line 448, in run
    do_run(
  File "C:\Users\Gustav\AppData\Roaming\Python\Python38\site-packages\pipenv\core.py", line 2554, in do_run
    run_fn(*run_args, **run_kwargs)
  File "C:\Users\Gustav\AppData\Roaming\Python\Python38\site-packages\pipenv\core.py", line 2475, in do_run_nt
    p = _launch_windows_subprocess(script)
  File "C:\Users\Gustav\AppData\Roaming\Python\Python38\site-packages\pipenv\core.py", line 2454, in _launch_windows_subprocess
    command = system_which(script.command)
  File "C:\Users\Gustav\AppData\Roaming\Python\Python38\site-packages\pipenv\core.py", line 1638, in system_which
    result = fallback_which(command, allow_global=True)
  File "C:\Users\Gustav\AppData\Roaming\Python\Python38\site-packages\pipenv\core.py", line 1584, in fallback_which
    result = find_python(finder, command)
  File "C:\Users\Gustav\AppData\Roaming\Python\Python38\site-packages\pipenv\utils.py", line 2196, in find_python
    result = finder.find_python_version(line)
  File "C:\Users\Gustav\AppData\Roaming\Python\Python38\site-packages\pipenv\vendor\pythonfinder\pythonfinder.py", line 262, in find_python_version
    version_dict = self.parse_major(major, minor=minor, patch=patch, arch=arch)
  File "C:\Users\Gustav\AppData\Roaming\Python\Python38\site-packages\pipenv\vendor\pythonfinder\pythonfinder.py", line 209, in parse_major
    int(version_dict["major"]) if version_dict.get("major") is not None else major
ValueError: invalid literal for int() with base 10: '.\\ex.py'

Steps to replicate

> # Create a file `ex.py` that contains only `import requests`.
> Set-Content ex.py "import requests"
> # For some reason, the next command pops up a number of console windows.
> # I don't know why this happens - the subcommands should be run in the existing console surely?
> py -m pipenv install requests
> # The next command works fine - runs with no output
> py -m pipenv run ex.py
> # The next command generates the traceback
> py -m pipenv run .\ex.py

Note that this is a major usability issue, as Powershell filename completion always adds a .\ prefix.


$ pipenv --support

Pipenv version: '2020.6.2'

Pipenv location: 'C:\\Users\\Gustav\\AppData\\Roaming\\Python\\Python38\\site-packages\\pipenv'

Python location: 'C:\\Users\\Gustav\\AppData\\Local\\Programs\\Python\\Python38\\python.exe'

Python installations found:

  • 3.8.3: C:\Users\Gustav\AppData\Local\Programs\Python\Python38\python.exe

PEP 508 Information:

{'implementation_name': 'cpython',
 'implementation_version': '3.8.3',
 'os_name': 'nt',
 'platform_machine': 'AMD64',
 'platform_python_implementation': 'CPython',
 'platform_release': '10',
 'platform_system': 'Windows',
 'platform_version': '10.0.19041',
 'python_full_version': '3.8.3',
 'python_version': '3.8',
 'sys_platform': 'win32'}

System environment variables:

  • ALLUSERSPROFILE
  • APPDATA
  • COMMONPROGRAMFILES
  • COMMONPROGRAMFILES(X86)
  • COMMONPROGRAMW6432
  • COMPUTERNAME
  • COMSPEC
  • DRIVERDATA
  • GIT_INSTALL_ROOT
  • HOMEDRIVE
  • HOMEPATH
  • LOCALAPPDATA
  • LOGONSERVER
  • NUMBER_OF_PROCESSORS
  • ONEDRIVE
  • ONEDRIVECONSUMER
  • OS
  • PATH
  • PATHEXT
  • POWERSHELL_DISTRIBUTION_CHANNEL
  • PROCESSOR_ARCHITECTURE
  • PROCESSOR_IDENTIFIER
  • PROCESSOR_LEVEL
  • PROCESSOR_REVISION
  • PROGRAMDATA
  • PROGRAMFILES
  • PROGRAMFILES(X86)
  • PROGRAMW6432
  • PSMODULEPATH
  • PUBLIC
  • SYSTEMDRIVE
  • SYSTEMROOT
  • TEMP
  • TMP
  • USERDOMAIN
  • USERDOMAIN_ROAMINGPROFILE
  • USERNAME
  • USERPROFILE
  • VIRTUAL_ENV_DISABLE_PROMPT
  • WINDIR
  • WORK_DIRECTORY
  • WSLENV
  • WT_PROFILE_ID
  • WT_SESSION
  • PIP_DISABLE_PIP_VERSION_CHECK
  • PYTHONDONTWRITEBYTECODE
  • PIP_SHIMS_BASE_MODULE
  • PIP_PYTHON_PATH
  • PYTHONFINDER_IGNORE_UNSUPPORTED

PipenvÔÇôspecific environment variables:

DebugÔÇôspecific environment variables:

  • PATH: C:\Program Files\PowerShell\7;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Docker\Docker\resources\bin;C:\ProgramData\DockerDesktop\version-bin;C:\Program Files\PowerShell\7\;C:\Users\Gustav\scoop\apps\cyg\current\bin;C:\Users\Gustav\scoop\shims;C:\Users\Gustav\AppData\Local\Microsoft\WindowsApps;C:\Users\Gustav\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\Gustav\.local\bin;C:\Users\Gustav\.local\scripts;C:\Users\Gustav\AppData\Local\Microsoft\WindowsApps

Contents of Pipfile ('D:\Work\Scratch\tester\Pipfile'):

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

[dev-packages]

[packages]
requests = "*"

[requires]
python_version = "3.8"

Contents of Pipfile.lock ('D:\Work\Scratch\tester\Pipfile.lock'):

{
    "_meta": {
        "hash": {
            "sha256": "acbc8c4e7f2f98f1059b2a93d581ef43f4aa0c9741e64e6253adff8e35fbd99e"
        },
        "pipfile-spec": 6,
        "requires": {
            "python_version": "3.8"
        },
        "sources": [
            {
                "name": "pypi",
                "url": "https://pypi.org/simple",
                "verify_ssl": true
            }
        ]
    },
    "default": {
        "certifi": {
            "hashes": [
                "sha256:5930595817496dd21bb8dc35dad090f1c2cd0adfaf21204bf6732ca5d8ee34d3",
                "sha256:8fc0819f1f30ba15bdb34cceffb9ef04d99f420f68eb75d901e9560b8749fc41"
            ],
            "version": "==2020.6.20"
        },
        "chardet": {
            "hashes": [
                "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae",
                "sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691"
            ],
            "version": "==3.0.4"
        },
        "idna": {
            "hashes": [
                "sha256:7588d1c14ae4c77d74036e8c22ff447b26d0fde8f007354fd48a7814db15b7cb",
                "sha256:a068a21ceac8a4d63dbfd964670474107f541babbd2250d61922f029858365fa"
            ],
            "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
            "version": "==2.9"
        },
        "requests": {
            "hashes": [
                "sha256:b3559a131db72c33ee969480840fff4bb6dd111de7dd27c8ee1f820f4f00231b",
                "sha256:fe75cc94a9443b9246fc7049224f75604b113c36acb93f87b80ed42c44cbb898"
            ],
            "index": "pypi",
            "version": "==2.24.0"
        },
        "urllib3": {
            "hashes": [
                "sha256:3018294ebefce6572a474f0604c2021e33b3fd8006ecd11d62107a5d2a963527",
                "sha256:88206b0eb87e6d677d424843ac5209e3fb9d0190d0ee169599165ec25e9d9115"
            ],
            "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' and python_version < '4'",
            "version": "==1.25.9"
        }
    },
    "develop": {}
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions