Opened 5 years ago

Last modified 5 years ago

#59746 assigned defect

py36-pip: ModuleNotFoundError: No module named 'pip._internal'

Reported by: ParityError Owned by: stromnov (Andrey Stromnov)
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc:
Port: py-pip

Description

I have an issue after using port select with pip; it seems I have to invoke sudo for any pip command, otherwise I receive an error:

$ python --version
Python 3.6.9

$ which python
/opt/local/bin/python

$ sudo port select --set pip pip36
Selecting 'pip36' for 'pip' succeeded. 'pip36' is now active.

$ which pip
/opt/local/bin/pip

$ pip --version
Traceback (most recent call last):
  File "/opt/local/bin/pip", line 11, in <module>
    load_entry_point('pip==19.3.1', 'console_scripts', 'pip')()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pkg_resources/__init__.py", line 489, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2852, in load_entry_point
    return ep.load()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2443, in load
    return self.resolve()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2449, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
ModuleNotFoundError: No module named 'pip._internal'

$ sudo pip --version
pip 19.3.1 from /opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip (python 3.6)

As you can see pip works with sudo but not without. I believe at one time I didn't need to use sudo when using pip for most common options. Is there some way to correct this issue? Thank you.

Change History (4)

comment:1 Changed 5 years ago by ParityError

Port: py36-pip added

comment:2 Changed 5 years ago by jmroot (Joshua Root)

Owner: set to stromnov
Port: py-pip added; py36-pip removed
Status: newassigned
Summary: ModuleNotFoundError: No module named 'pip._internal'py36-pip: ModuleNotFoundError: No module named 'pip._internal'

Do you have any environment variables set that affect python's behaviour? Those would be cleared by sudo with a default configuration.

comment:3 Changed 5 years ago by ParityError

No environment variables are set regarding Python at all. Why this is happening is definitely a mystery.

comment:4 Changed 5 years ago by ParityError

Okay, I believe that I've tracked down the issue. The pip directory in /opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip permissions was set to 200, which is only user write. I chmod it to 755 and it seems to work as expected now.

$ ls -lat | grep pip
d-w-------    9 root  wheel        288 Nov 22 00:01 pip

$ sudo chmod -R 755 pip

$ pip --version
pip 19.3.1 from /opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip (python 3.6)

Any idea why it would be set at 200 in the first place? Thank you.

Note: See TracTickets for help on using tickets.