Search code examples
pythonpippipenv

After successful pip3 install, I still get ModuleNotFoundError: No module named 'ConfigParser'


I'm installing a complex Python software project. 5 engineers worked on this for some years, but they are all gone now, so I need to figure this out on my own. I run:

/usr/local/bin/pipenv lock

And I get a long set of errors, one of which is:

ModuleNotFoundError: No module named 'ConfigParser'

So I run:

pip3 install ConfigParser

I get:

Collecting ConfigParser
Downloading configparser-5.2.0-py3-none-any.whl (19 kB)
Installing collected packages: ConfigParser
Successfully installed ConfigParser-5.2.0

Then I repeat:

/usr/local/bin/pipenv lock

I get exactly the same set of errors:

Locking [dev-packages] dependencies...
Building requirements...
Resolving dependencies...
✔ Success! 
Locking [packages] dependencies...
Building requirements...
Resolving dependencies...
✘ Locking Failed! 

And a long set of errors that look like this:

ERROR:pip.subprocessor:Command errored out with exit status 1:
 command: /root/.local/share/virtualenvs/blueflow-c7ciKYpf/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pipenv-dmt2c0oj-build/psycopg2_75c2812bb7024f2aac1a6aa1c5c2cef9/setup.py'"'"'; __file__='"'"'/tmp/pipenv-dmt2c0oj-build/psycopg2_75c2812bb7024f2aac1a6aa1c5c2cef9/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' --no-user-cfg egg_info --egg-base /tmp/pip-pip-egg-info-35pnz9zt
     cwd: /tmp/pipenv-dmt2c0oj-build/psycopg2_75c2812bb7024f2aac1a6aa1c5c2cef9/
Complete output (6 lines):
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/pipenv-dmt2c0oj-build/psycopg2_75c2812bb7024f2aac1a6aa1c5c2cef9/setup.py", line 225
    except Warning, w:
                  ^
SyntaxError: invalid syntax
----------------------------------------
ERROR:pip.subprocessor:Command errored out with exit status 1:
 command: /root/.local/share/virtualenvs/blueflow-c7ciKYpf/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pipenv-dmt2c0oj-build/psycopg2_418a10a77a924c508bc796a1db4c47ae/setup.py'"'"'; __file__='"'"'/tmp/pipenv-dmt2c0oj-build/psycopg2_418a10a77a924c508bc796a1db4c47ae/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' --no-user-cfg egg_info --egg-base /tmp/pip-pip-egg-info-91fiybpm
     cwd: /tmp/pipenv-dmt2c0oj-build/psycopg2_418a10a77a924c508bc796a1db4c47ae/
Complete output (5 lines):
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/pipenv-dmt2c0oj-build/psycopg2_418a10a77a924c508bc796a1db4c47ae/setup.py", line 50, in <module>
    import ConfigParser
ModuleNotFoundError: No module named 'ConfigParser'
----------------------------------------
CRITICAL:pipenv.patched.notpip._internal.resolution.resolvelib.factory:Could not find a version that satisfies the requirement psycopg2 (from versions: 2.0.10, 2.0.11, 2.0.12, 2.0.13, 2.0.14, 2.2.0, 2.2.1, 2.2.2, 2.3.0, 2.3.1, 2.3.2, 2.4, 2.4.1, 2.4.2, 2.4.3, 2.4.4, 2.4.5, 2.4.6, 2.5, 2.5.1, 2.5.2, 2.5.3, 2.5.4, 2.5.5, 2.6, 2.6.1, 2.6.2, 2.7, 2.7.1, 2.7.2, 2.7.3, 2.7.3.1, 2.7.3.2, 2.7.4, 2.7.5, 2.7.6, 2.7.6.1, 2.7.7, 2.8, 2.8.1, 2.8.2, 2.8.3, 2.8.4, 2.8.5, 2.8.6, 2.9, 2.9.1, 2.9.2, 2.9.3)
[ResolutionFailure]:   File "/usr/local/lib/python3.6/site-packages/pipenv/resolver.py", line 743, in _main
[ResolutionFailure]:       resolve_packages(pre, clear, verbose, system, write, requirements_dir, packages, dev)
[ResolutionFailure]:   File "/usr/local/lib/python3.6/site-packages/pipenv/resolver.py", line 711, in resolve_packages
[ResolutionFailure]:       requirements_dir=requirements_dir,
[ResolutionFailure]:   File "/usr/local/lib/python3.6/site-packages/pipenv/resolver.py", line 693, in resolve
[ResolutionFailure]:       req_dir=requirements_dir
[ResolutionFailure]:   File "/usr/local/lib/python3.6/site-packages/pipenv/utils.py", line 1385, in resolve_deps
[ResolutionFailure]:       req_dir=req_dir,
[ResolutionFailure]:   File "/usr/local/lib/python3.6/site-packages/pipenv/utils.py", line 1106, in actually_resolve_deps
[ResolutionFailure]:       resolver.resolve()
[ResolutionFailure]:   File "/usr/local/lib/python3.6/site-packages/pipenv/utils.py", line 884, in resolve
[ResolutionFailure]:       raise ResolutionFailure(message=str(e))
[pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
  You can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.
  Hint: try $ pipenv lock --pre if it is a pre-release dependency.
ERROR: No matching distribution found for psycopg2                        

I'm thinking pipenv is using some paths that are different from wherever pip3 installs things? How could I find out?


Solution

  • The only way I found to get traction on this problem was to add more and more to the PATH in my .bashrc file:

    export PATH="$PATH:/root/.local/lib/python3.6/site-packages/:/usr/local/lib/python3.6/site-packages/"
    export PATH="$PATH:/usr/local/bin/pipenv:/usr/local/bin/"
    export PATH="$PATH:/root/.local/:/root/.local/bin/"
    export PATH="$PATH:/root/blueflow/blueflow/bin/"
    

    And the same for the ec2-user of course.

    Doing everything as root did simplify some of the problems, but of course it introduces great security risks.