Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: No module named basecommand #3218

Closed
skytect opened this issue Nov 14, 2018 · 6 comments
Closed

ImportError: No module named basecommand #3218

skytect opened this issue Nov 14, 2018 · 6 comments
Labels
OS: Linux This issue affects the Linux Operating System. Type: Bug 🐛 This issue is a bug.

Comments

@skytect
Copy link

skytect commented Nov 14, 2018

Issue description

Whenever I type in any pipenv command including pipenv itself, I encounter an import error.

Expected result

  • pipenv to return a list of pipenv commands
  • Various pipenv commands to do what they are supposed to do accordingly

Actual result

Traceback (most recent call last):
  File "/usr/bin/pipenv", line 7, in <module>
    from pipenv import cli
  File "/usr/lib/python2.7/site-packages/pipenv/__init__.py", line 23, in <module>
    from .cli import cli
  File "/usr/lib/python2.7/site-packages/pipenv/cli.py", line 26, in <module>
    from .utils import is_valid_url
  File "/usr/lib/python2.7/site-packages/pipenv/utils.py", line 59, in <module>
    from .vendor.requirementslib import Requirement
  File "/usr/lib/python2.7/site-packages/pipenv/vendor/requirementslib/__init__.py", line 6, in <module>
    from .models import Requirement, Lockfile, Pipfile
  File "/usr/lib/python2.7/site-packages/pipenv/vendor/requirementslib/models/__init__.py", line 8, in <module>
    from .requirements import Requirement
  File "/usr/lib/python2.7/site-packages/pipenv/vendor/requirementslib/models/requirements.py", line 15, in <module>
    from .markers import PipenvMarkers
  File "/usr/lib/python2.7/site-packages/pipenv/vendor/requirementslib/models/markers.py", line 6, in <module>
    from .utils import validate_markers, filter_none
  File "/usr/lib/python2.7/site-packages/pipenv/vendor/requirementslib/models/utils.py", line 9, in <module>
    from .._compat import Link
  File "/usr/lib/python2.7/site-packages/pipenv/vendor/requirementslib/_compat.py", line 55, in <module>
    Command = do_import("basecommand", "Command")
  File "/usr/lib/python2.7/site-packages/pipenv/vendor/requirementslib/_compat.py", line 35, in do_import
    _tmp = importlib.import_module(pip9)
  File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
ImportError: No module named basecommand

Steps to replicate

OS: Amazon Linux 2 on an ec2 instance
pipenv version: Successfully installed pipenv-2018.10.13 (I can't run pipenv -V)
pip -V: pip 18.1 from /home/ec2-user/.local/lib/python3.7/site-packages/pip (python 3.7)

I tried both in an empty directory and one with the following pipfile:

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

[packages]
pyyaml = "*"
pika = "*"
"psycopg2" = "*"
aiohttp = "*"

[dev-packages]

[requires]
python_version = "3.7"

I am unable to run pipenv --support as it also returns ImportError: No module named basecommand

@dennisverspuij
Copy link

dennisverspuij commented Nov 14, 2018

Accidentally stumbled on this, but I have had similar troubles lately!
Probably you installed RPM package system-rpm-config lately, as dependency for python36-virtualenv or python36-devel. The package installs /etc/profile.d/python-install-layout.(c)sh which sets PYTHON_INSTALL_LAYOUT="amzn" globally for users logged in with bash/csh. The setting messed up all my pipenv, pipsi, tox related environments. To workaround call PYTHON_INSTALL_LAYOUT= pipenv or put unset PYTHON_INSTALL_LAYOUT in your personal e.g. .bash_profile to not have to think about it. I put it explicitely in each pipenv invocations in cron jobs, init scripts, wsgi, just to be sure not to be caught by this stupid setting, that ought to be for building RPM packages. If you still have troubles when unsetting the variable prior to calling pipenv you may have to reinstall it with the variable unset.

@frostming
Copy link
Contributor

@skytect @dennisverspuij Thanks for reporting, can you verify the issue against #3217 ?

@dennisverspuij
Copy link

@frostming I am not sure whether that is relevant, it is the distutils package bundled in the standard library with Python, that behaves differently according to PYTHON_INSTALL_LAYOUT. I don't think pipenv can do anything about it. Imho the layout does not really matter as long as it is used consistently, if not these troubles arise. Imho it should never be set through a global shell init script, because these are not loaded when run through cron, wsgi, etcetera, causing problems when during those invocations environments are mutated.

@dennisverspuij
Copy link

So it is very bad that AMI linux sets it, if you pip install something before/after system-rpm-config is installed things get messed up.

@techalchemy
Copy link
Member

I deleted the script in question before the current release, and there is no code in pipenv that operates this way anymore. Also, There is a whole lot of text here talking about a lot of environment variables and distro specific paths which as far as I can tell have nothing to do with pipenv, for example I have no clue what the various environment variables you describe do and I don't really have the bandwidth to spend learning that. If this isn't fixed in the current release let me know and we can try to simplify the conversation and distill it down to "the problem" and "the solution" in a new issue

sorry for the annoyance, for now the solution is to upgrade

@techalchemy techalchemy added Type: Bug 🐛 This issue is a bug. OS: Linux This issue affects the Linux Operating System. labels Nov 15, 2018
@Arlington1985
Copy link

I had a problem importing json, I have solved it just deleting virtual env folder from .virtualenv directory and it initiated the whole process again. I know why it happened to me. It was because of the old environment was created with python version 3.6 and later I switched to 3.7. I deleted python 3.6 and it broke up my old staff which related with that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OS: Linux This issue affects the Linux Operating System. Type: Bug 🐛 This issue is a bug.
Projects
None yet
Development

No branches or pull requests

5 participants