1

I am very new to python/pip, and at this point I'm just fiddling with things, trying to get my environment installed so I can start testing the language.

I had PIP properly installed,but was trying to find something that might help me integrate an interpreter into Jetbrains PyCharm. I found something called PIPEnv (https://pypi.org/project/pipenv/) and installed it, but now it seemed to have broken PIP

example@my-computer:~/hooks$ pip install pipenv
Collecting pipenv
Downloading https://files.pythonhosted.org/packages/bb/15/b155a5c0d19ce41609f50bb70a37e0de092b453ec4bd2eac59e53a2c3227/pipenv-2018.11.26-py2-none-any.whl (5.2MB)
100% |████████████████████████████████| 5.2MB 310kB/s 
Collecting enum34; python_version < "3" (from pipenv)
Downloading https://files.pythonhosted.org/packages/c5/db/e56e6b4bbac7c4a06de1c50de6fe1ef3810018ae11732a50f15f62c7d050/enum34-1.1.6-py2-none-any.whl
Collecting virtualenv (from pipenv)
Downloading https://files.pythonhosted.org/packages/7e/1b/6c00d57127608793e16e8b7f813e64d58a1938505c42fe190d1386ab41e1/virtualenv-16.4.0-py2.py3-none-any.whl (2.0MB)
100% |████████████████████████████████| 2.0MB 821kB/s 
Collecting typing; python_version < "3.5" (from pipenv)
Downloading https://files.pythonhosted.org/packages/cc/3e/29f92b7aeda5b078c86d14f550bf85cff809042e3429ace7af6193c3bc9f/typing-3.6.6-py2-none-any.whl
Collecting certifi (from pipenv)
Downloading https://files.pythonhosted.org/packages/9f/e0/accfc1b56b57e9750eba272e24c4dddeac86852c2bebd1236674d7887e8a/certifi-2018.11.29-py2.py3-none-any.whl (154kB)
100% |████████████████████████████████| 163kB 8.6MB/s 
Collecting virtualenv-clone>=0.2.5 (from pipenv)
Downloading https://files.pythonhosted.org/packages/e3/d9/d9c56deb483c4d3289a00b12046e41428be64e8236fa210111a1f57cc42d/virtualenv_clone-0.5.1-py2.py3-none-any.whl
Collecting pip>=9.0.1 (from pipenv)
Downloading https://files.pythonhosted.org/packages/d7/41/34dd96bd33958e52cb4da2f1bf0818e396514fd4f4725a79199564cd0c20/pip-19.0.2-py2.py3-none-any.whl (1.4MB)
100% |████████████████████████████████| 1.4MB 1.2MB/s 
Collecting setuptools>=36.2.1 (from pipenv)
Downloading https://files.pythonhosted.org/packages/d1/6a/4b2fcefd2ea0868810e92d519dacac1ddc64a2e53ba9e3422c3b62b378a6/setuptools-40.8.0-py2.py3-none-any.whl (575kB)
100% |████████████████████████████████| 583kB 2.7MB/s 
Installing collected packages: enum34, virtualenv, typing, certifi, virtualenv-clone, pip, setuptools, pipenv
Successfully installed certifi-2018.11.29 enum34-1.1.6 pip-19.0.2 pipenv-2018.11.26 setuptools-40.8.0 typing-3.6.6 virtualenv-16.4.0 virtualenv-clone-0.5.1
example@my-computer:~/hooks$ pip list
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
from pip import main
ImportError: cannot import name main

Any help would be great.

user1015214
  • 2,733
  • 10
  • 36
  • 66
  • 3
    Possible duplicate of [Error after upgrading pip: cannot import name 'main'](https://stackoverflow.com/questions/49836676/error-after-upgrading-pip-cannot-import-name-main) – J. Taylor Feb 10 '19 at 04:44

3 Answers3

2

You can try to uninstall pip and pip env.

Then reinstall pip and then try to again install pipenv. If this time it does not work then you need to use pip and virtualenv instead of pip env.

Uninstall both of them and this time install pip and virtualenv
You can configure pycharm to work with virtualenv.
Anyway these commands worked for me
For uninstalling

python3 -m pip3 uninstall pip3



sudo -H pip3 install --upgrade pip
sudo -H pip3 install pipenv

Now try executing 'pipenv'
If it still does not work try upgrading your python3.
If you are still using python2.7 then replace pip3 with pip

Anonymous
  • 596
  • 1
  • 9
  • 26
0

We don't use PIPEnv but have found that the latest pip release is causing import errors in a few places in our build systems. Since the code hadn't changed since the last successful build I am strongly suspecting this pip version (19.0.2) is broken/incompatible in some way. The solution for us will be to go back to 19.0.1 which has been working fine for a while. We'll be doing this inside the virtualenv not at the system level.

0

I have found in this post (AttributeError: Module Pip has no attribute 'main') a patch for migrating to most recent pup versions for this import problem in some versions of pip. Making code to support but newer and older versions, the workaround for importing the pip 'main' module results as here:

if hasattr(pip,'main'): pipm=pip.main else: from pip import _internal pipm=pip._internal.main

Lucioric2000
  • 490
  • 5
  • 9