Pipenv: import JSON error

Created on 3 Apr 2019  Â·  9Comments  Â·  Source: pypa/pipenv

Issue description

Getting the error:

C:\Users\rohan\Desktop\pipenv test>pipenv install requests
Warning: Your Pipfile requires python_version 3.6, but you are using 3.7.3 (C:\Users\rohan\.\r\S\python.exe).
  $ pipenv --rm and rebuilding the virtual environment may resolve the issue.
  $ pipenv check will surely fail.
Installing requests…
Adding requests to Pipfile's [packages]…
Installation Succeeded
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
Locking Failed!
Traceback (most recent call last):
  File "c:/users/rohan/appdata/local/programs/python/python37/lib/site-packages/pipenv/resolver.py", line 3, in <module>
    import json
ModuleNotFoundError: No module named 'json'
File "c:/users/rohan/appdata/local/programs/python/python37/lib/site-packages/pipenv/resolver.py", line 3, in <module>
    import json
ModuleNotFoundError: No module named 'json'

Been trying to fix it for hours with staff on the Python Discord server with 15,000 members. After 2 hours they sent me here.

Expected result

To install requests...

Actual result

C:\Users\rohan\Desktop\pipenv test>pipenv install --verbose requests
Warning: Your Pipfile requires python_version 3.6, but you are using 3.7.3 (C:\Users\rohan\.\r\S\python.exe).
  $ pipenv --rm and rebuilding the virtual environment may resolve the issue.
  $ pipenv check will surely fail.
Installing requests…
[    ] Installing...Installing 'requests'
$ ['C:\\Users\\rohan\\.virtualenvs\\rohan-D2oimpxC\\Scripts\\pip.exe', 'install', '--verbose', '--upgrade', 'requests', '-i', 'https://pypi.org/simple']
Adding requests to Pipfile's [packages]…
Installation Succeeded
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
Locking Failed!
Traceback (most recent call last):
  File "c:/users/rohan/appdata/local/programs/python/python37/lib/site-packages/pipenv/resolver.py", line 3, in <module>
    import json
ModuleNotFoundError: No module named 'json'
File "c:/users/rohan/appdata/local/programs/python/python37/lib/site-packages/pipenv/resolver.py", line 3, in <module>
    import json
ModuleNotFoundError: No module named 'json'

Steps to replicate

No Pipfile created


Please run $ pipenv --support, and paste the results here. Don't put backticks (`) around it! The output already contains Markdown formatting.

C:\Users\rohanDesktop\pipenv test>pipenv --support

$ pipenv --support

Pipenv version: '2018.11.26'

Pipenv location: 'c:\\users\\rohan\\appdata\\local\\programs\\python\\python37\\lib\\site-packages\\pipenv'

Python location: 'c:\\users\\rohan\\appdata\\local\\programs\\python\\python37\\python.exe'

Python installations found:

  • 3.7.3: C:\Users\rohan\AppData\Local\Programs\Python\Python37\python.exe

PEP 508 Information:

{'implementation_name': 'cpython',
 'implementation_version': '3.7.3',
 'os_name': 'nt',
 'platform_machine': 'AMD64',
 'platform_python_implementation': 'CPython',
 'platform_release': '10',
 'platform_system': 'Windows',
 'platform_version': '10.0.17134',
 'python_full_version': '3.7.3',
 'python_version': '3.7',
 'sys_platform': 'win32'}

System environment variables:

  • ALLUSERSPROFILE
  • APPDATA
  • COMMONPROGRAMFILES
  • COMMONPROGRAMFILES(X86)
  • COMMONPROGRAMW6432
  • COMPUTERNAME
  • COMSPEC
  • DRIVERDATA
  • ETHEREUM_SOCKET
  • FPS_BROWSER_APP_PROFILE_STRING
  • FPS_BROWSER_USER_PROFILE_STRING
  • HOMEDRIVE
  • HOMEPATH
  • LOCALAPPDATA
  • LOGONSERVER
  • NUMBER_OF_PROCESSORS
  • ONEDRIVE
  • ONEDRIVECONSUMER
  • OS
  • PATH
  • PATHEXT
  • PROCESSOR_ARCHITECTURE
  • PROCESSOR_IDENTIFIER
  • PROCESSOR_LEVEL
  • PROCESSOR_REVISION
  • PROGRAMDATA
  • PROGRAMFILES
  • PROGRAMFILES(X86)
  • PROGRAMW6432
  • PROMPT
  • PSMODULEPATH
  • PUBLIC
  • PYCHARM COMMUNITY EDITION
  • SESSIONNAME
  • SYSTEMDRIVE
  • SYSTEMROOT
  • TEMP
  • TMP
  • USERDOMAIN
  • USERDOMAIN_ROAMINGPROFILE
  • USERNAME
  • USERPROFILE
  • WINDIR
  • 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 (x86)\Intel\iCLS Client\;C:\Program Files (x86)\Razer Chroma SDK\bin;C:\Program Files\Razer Chroma SDK\bin;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Users\rohan\AppData\Local\Microsoft\WindowsApps;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Users\rohan\Desktop;C:\Program Files (x86)\OpenVPN\bin;C:\Users\rohan\AppData\Local\Programs\Python36;C:\Program Files\Git\cmd;C:\WINDOWS\System32\OpenSSH\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\PuTTY\;C:\ffmpeg-4.1-win64-static\bin;C:\Users\rohan\AppData\Local\Programs\Python\Python37\Scripts\;C:\Users\rohan\AppData\Local\Programs\Python\Python37\;C:\Users\rohan\AppData\Local\Microsoft\WindowsApps;C:\Users\rohan\AppData\Local\atom\bin;C:\Program Files\heroku\bin;C:\Program Files\JetBrains\PyCharm Community Edition 2019.1\bin;

Contents of Pipfile ('C:\Users\rohan\Pipfile'):

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

[dev-packages]

[packages]
requests = "*"
json = "*"
request = "*"
numpy = "*"

[requires]
python_version = "3.6"

C:\Users\rohanDesktop\pipenv test>

If you're on macOS, run the following:

$ pipenv --support | pbcopy

If you're on Windows, run the following:

> pipenv --support | clip

If you're on Linux, run the following:

$ pipenv --support | xclip

Most helpful comment

@RohanRadia May I ask you do the following and see the results

  1. C:\Users\rohan\AppData\Local\Programs\Python\Python37\python.exe -c "import json"
  2. pipenv --rm & pipenv install requests

All 9 comments

Can you remove the json from Pipfile because it is an invalid dependency.

Let's see if I can beat the 15,000 people LOL.

Can't remove JSON from profile if it doesn't create a pipfile.

@RohanRadia but I see it list in 'C:\Users\rohan\Pipfile'

Removed all the dependencies including JSON. Same import json error.

@RohanRadia Seems your python interpreter's JSON module is broken.

Can't be. We did a full re-install twice yesterday. Should I test JSON in a normal put on file?

@RohanRadia May I ask you do the following and see the results

  1. C:\Users\rohan\AppData\Local\Programs\Python\Python37\python.exe -c "import json"
  2. pipenv --rm & pipenv install requests

1)

C:\Users\rohan>C:\Users\rohanAppData\Local\Programs\Python\Python37\python.exe -c "import json"

C:\Users\rohan>

2)

C:\Users\rohanDesktop\pipenv test>pipenv --rm & pipenv install requests
Removing virtualenv (C:\Users\rohan.virtualenvs\rohan-D2oimpxC)…
Creating a virtualenv for this project…
Pipfile: C:\Users\rohanPipfile
Using C:/Users/rohan/AppData/Local/Programs/Python/Python37/python.exe (3.7.3) to create virtualenv…
[ ==] Creating virtual environment...Using base prefix 'C:\Users\rohan\AppData\Local\Programs\Python\Python37'
New python executable in C:\Users\rohan.virtualenvs\rohan-D2oimpxC\Scripts\python.exe
Installing setuptools, pip, wheel...
done.
Running virtualenv with interpreter C:/Users/rohan/AppData/Local/Programs/Python/Python37/python.exe

Successfully created virtual environment!
Virtualenv location: C:\Users\rohan.virtualenvs\rohan-D2oimpxC
Installing requests…
Adding requests to Pipfile's [packages]…
Installation Succeeded
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
Success!
Updated Pipfile.lock (24c40d)!
Installing dependencies from Pipfile.lock (24c40d)…
================================ 6/6 - 00:00:09
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.

C:\Users\rohanDesktop\pipenv test>


Mhm, did it work all of sudden?

@RohanRadia No, it failed because you had an old virtualenv with a broken JSON module. Remove and create a new fixes the issue.

So there isn't any more problem here, close it now.

Was this page helpful?
0 / 5 - 0 ratings