Re: Broken pip

2018-08-31 Thread Michael F. Stemper
On 2018-08-29 16:02, Thomas Jollans wrote:
> On 08/29/2018 09:05 PM, Michael F. Stemper wrote:

>>> Also, PLEASE use Python 3. Still using Python 2 today is like still
>>> using Windows XP in early 2013.
>> I'm using the default version for the current release of my
>> OS (Ubuntu 16.04 LTS):

>> My understanding is that when I get around to upgrading to 18.04 LTS,
>> python3 will be the default.
>>
>> Since I don't hard-code a version in any of my programs, but simply
>> write "#!/usr/bin/python", all of my programs will automatically change
>> to the new version then.
> 
> No, actually.
> 
> As I understand it, Ubuntu 18.04 LTS uses python2 a lot less, and I
> don't think it's included in the default install. However, it's still in
> main, the name of the package is still "python", and it's still required
> by some common software... (including the recommended personal backup
> tool, duplicity :-/)

Interesting. I based my statement on
, which says:
"Python 3 only on the default installs for desktop, server, [...]"

Since this says "plans", not "accomplishments", I searched further
and found

where they say: "Python 2 is no longer installed by default."

I'm having trouble parsing this. If it's not in the default
installation, I'm not sure how it can be required. Conversely, if
it's required, I'm not sure how it can be left out of the default
installation.

> In any case, as per PEP 394, /usr/bin/python continues to point to
> Python 2.7 (if installed), it it will likely remain that way for the
> foreseeable future. (including, presumably, Ubuntu 20.04 LTS)
> 
> PEP 394: https://www.python.org/dev/peps/pep-0394/

Boy, that led me down any number of rabbit holes. :-> I spent most of
yesterday following where it led me. I'm not yet persuaded, but at least
I'm better aware of some of the issues.

>> If I was to change all of my programs to say "#!/usr/bin/python3", I'd
>> have a slight head-start. However, then I'd need to change them all
>> again when python 4 came out. And python 5.
>>
>> I prefer to maintain version independence, or at least to avoid
>> implementing version dependence.
> 
> You should know that there were some (deliberate) incompatible changes
> (vastly for the better) in Python 3.0 (almost ten years ago). It's
> normally easy to port your code, and not too hard to write code that
> runs on both Python 2 and Python 3 if required, but in any case you have
> to do this consciously,

I definitely do that. I use "//" for integer division, I never use
either "print" or "print()". I'm not sophisticated enough to do version
sniffing or binary files or non-ASCII text.

Every time I change one of my modules, I run the test code under both
python and python3.

By PEP 394:

"One exception to this is scripts that are deliberately written to be
source compatible with both Python 2.x and 3.x. Such scripts may
continue to use python on their shebang line."

> As for the "Python 4 problem" – at the moment nobody knows whether there
> will even /be/ a Python 4.

For what it's worth,

says:
"The problem with this code is what happens when Python 4 comes out?"


Anyhow, you've given me a lot to think about, for which I thank you.

-- 
Michael F. Stemper
Exodus 22:21
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Broken pip

2018-08-29 Thread Thomas Jollans

On 08/29/2018 09:05 PM, Michael F. Stemper wrote:


I can certainly see a use case for user-specific versions of
modules, and even user-specific presence of modules. For
instance, at school, different researchers might need to have
specific modules for their work. Possibly one person is doing
something with a 3PP built on a specific version of a module
that would be incompatible with a later version.

However, why would I want this on my home servers? It seems to
me that having different versions for different people on my
home network would rapidly become a maintenance problem.

I'm the only one who writes code here. If I was to tell somebody,
"Hey, look at what I wrote," it'd be nice if their environment
had all of the same stuff as mine.
I'd stick with distribution packages as far as possible if I were you. 
The nice thing about installing custom packages from PyPI in ~/.local 
only is that while I /might/ mess up my own environment, I'm not risking 
the functionality of system components/daemons/etc. running as root. But 
I'm no sysadmin.


(I realize that you're the messenger, not the designer. It seems
as if my beef is probably with Canonical or even Debian.)
Oh no, the problem exists on every Linux distro, and I assume Ruby, Perl 
and R users have the same kinds of problems. Heck, I've had similar 
problems with LaTeX/TeXlive...



Also, PLEASE use Python 3. Still using Python 2 today is like still
using Windows XP in early 2013.

I'm using the default version for the current release of my
OS (Ubuntu 16.04 LTS):

user@host$ ls -lrtd python python?
lrwxrwxrwx 1 root root 9 Nov 22  2016 python3 -> python3.5
lrwxrwxrwx 1 root root 9 Nov 23  2017 python2 -> python2.7
lrwxrwxrwx 1 root root 9 Nov 23  2017 python -> python2.7
user@host$

My understanding is that when I get around to upgrading to 18.04 LTS,
python3 will be the default.

Since I don't hard-code a version in any of my programs, but simply
write "#!/usr/bin/python", all of my programs will automatically change
to the new version then.


No, actually.

As I understand it, Ubuntu 18.04 LTS uses python2 a lot less, and I 
don't think it's included in the default install. However, it's still in 
main, the name of the package is still "python", and it's still required 
by some common software... (including the recommended personal backup 
tool, duplicity :-/)


In any case, as per PEP 394, /usr/bin/python continues to point to 
Python 2.7 (if installed), it it will likely remain that way for the 
foreseeable future. (including, presumably, Ubuntu 20.04 LTS)


PEP 394: https://www.python.org/dev/peps/pep-0394/

If I was to change all of my programs to say "#!/usr/bin/python3", I'd
have a slight head-start. However, then I'd need to change them all
again when python 4 came out. And python 5.

I prefer to maintain version independence, or at least to avoid
implementing version dependence.


You should know that there were some (deliberate) incompatible changes 
(vastly for the better) in Python 3.0 (almost ten years ago). It's 
normally easy to port your code, and not too hard to write code that 
runs on both Python 2 and Python 3 if required, but in any case you have 
to do this consciously, and code written for Python 2 will not in 
general work unmodified on Python 3.


At least for new scripts, just use #!/usr/bin/python3 or #!/usr/bin/env 
python3.


As for the "Python 4 problem" – at the moment nobody knows whether there 
will even /be/ a Python 4. Maybe Python 4.0 will be the version after 
3.9 (doubtful IMHO). Maybe it'll come later. Maybe it never will. It 
certainly won't include any major breaking changes, and considering PEP 
394, I could imagine that when the time comes we will see 
/usr/bin/python3 pointing to /usr/bin/python4.0 (as silly as that sounds).


-- Thomas






--
https://mail.python.org/mailman/listinfo/python-list


Re: Broken pip

2018-08-29 Thread Michael F. Stemper
On 2018-08-29 03:10, Thomas Jollans wrote:
> On 2018-08-28 20:10, Michael F. Stemper wrote:
>> I'm trying to upgrade my pip on Ubuntu 16.04. I appear to have
>> buggered things up pretty well. (Details follow) Any suggestions
>> on how to undo this and get everything back to proper operation?
>>
>> Based on the information that I found at:
>> , I did the following:
>>
>> user@host$ pip --version
>> pip 9.0.1 from /home/user/.local/lib/python2.7/site-packages (python 2.7)
> 
> Apparently, you did it the "right" way before: installing anything
> system-wide with pip that has already been installed with distribution
> packages is fairly likely to break. Installing a newer pip in your home
> directory should normally work fine.
> 
> Opinions differ, but personally I *never* use "sudo pip": use "pip
> install --user" instead. This installs into ~/.local rather than /usr/local.

I can certainly see a use case for user-specific versions of
modules, and even user-specific presence of modules. For
instance, at school, different researchers might need to have
specific modules for their work. Possibly one person is doing
something with a 3PP built on a specific version of a module
that would be incompatible with a later version.

However, why would I want this on my home servers? It seems to
me that having different versions for different people on my
home network would rapidly become a maintenance problem.

I'm the only one who writes code here. If I was to tell somebody,
"Hey, look at what I wrote," it'd be nice if their environment
had all of the same stuff as mine.

(I realize that you're the messenger, not the designer. It seems
as if my beef is probably with Canonical or even Debian.)

> Also, PLEASE use Python 3. Still using Python 2 today is like still
> using Windows XP in early 2013.

I'm using the default version for the current release of my
OS (Ubuntu 16.04 LTS):

user@host$ ls -lrtd python python?
lrwxrwxrwx 1 root root 9 Nov 22  2016 python3 -> python3.5
lrwxrwxrwx 1 root root 9 Nov 23  2017 python2 -> python2.7
lrwxrwxrwx 1 root root 9 Nov 23  2017 python -> python2.7
user@host$

My understanding is that when I get around to upgrading to 18.04 LTS,
python3 will be the default.

Since I don't hard-code a version in any of my programs, but simply
write "#!/usr/bin/python", all of my programs will automatically change
to the new version then.

If I was to change all of my programs to say "#!/usr/bin/python3", I'd
have a slight head-start. However, then I'd need to change them all
again when python 4 came out. And python 5.

I prefer to maintain version independence, or at least to avoid
implementing version dependence.

-- 
Michael F. Stemper
If you take cranberries and stew them like applesauce they taste much
more like prunes than rhubarb does.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Broken pip

2018-08-29 Thread Sivan Greenberg
I used to get into that sort of lib chaos but then a few years ago I
stopped doing any python outside of virtualenv(s).

My 2c is use it always, use it more and then you’re free to use pip as the
only pkg manager for the project, with the occasional caveat that sometimes
you require non python libs installation through apt.

Sivan



On Wed, 29 Aug 2018 at 11:18 Thomas Jollans  wrote:

> On 2018-08-28 20:10, Michael F. Stemper wrote:
> > I'm trying to upgrade my pip on Ubuntu 16.04. I appear to have
> > buggered things up pretty well. (Details follow) Any suggestions
> > on how to undo this and get everything back to proper operation?
> >
> > Based on the information that I found at:
> > , I did the following:
> >
> > user@host$ pip --version
> > pip 9.0.1 from /home/user/.local/lib/python2.7/site-packages (python 2.7)
>
> Apparently, you did it the "right" way before: installing anything
> system-wide with pip that has already been installed with distribution
> packages is fairly likely to break. Installing a newer pip in your home
> directory should normally work fine.
>
> Opinions differ, but personally I *never* use "sudo pip": use "pip
> install --user" instead. This installs into ~/.local rather than
> /usr/local.
>
> i.e.: try
>
>   python -m pip install --upgrade --user pip
>
> If that works, see if
>
>   python -m pip --version
> and
>   pip --version
>
> work and show the same thing. If the latter doesn't work or shows an old
> version, you may have to make sure ~/.local/bin/pip has priority over
> /usr/bin/pip (e.g. by putting ~/.local/bin/ near the front of your $PATH)
>
> If things break, you now know how to undo the damage thanks to Larry ;-)
>
> Also, PLEASE use Python 3. Still using Python 2 today is like still
> using Windows XP in early 2013.
>
> https://pythonclock.org/
>
> -- Thomas
>
>
> > user@host$ pip install --upgrade pip
> > Collecting pip
> >   Downloading
> >
> https://files.pythonhosted.org/packages/5f/25/e52d3f31441505a5f3af41213346e5b6c221c9e086a166f3703d2ddaf940/pip-18.0-py2.py3-none-any.whl
> > (1.3MB)
> > 100% || 1.3MB 453kB/s
> > Installing collected packages: pip
> >   Found existing installation: pip 9.0.1
> > Uninstalling pip-9.0.1:
> >   Successfully uninstalled pip-9.0.1
> >   Rolling back uninstall of pip
> > Exception:
> > Traceback (most recent call last):
> >  [snip error traceback]
> > mkdir(name, mode)
> > OSError: [Errno 13] Permission denied:
> > '/usr/local/lib/python2.7/dist-packages/pip'
> > You are using pip version 9.0.1, however version 18.0 is available.
> > You should consider upgrading via the 'pip install --upgrade pip'
> command.
> > user@host$ pip --version
> > SError: [Errno 13] Permission denied:
> > '/usr/local/lib/python2.7/dist-packages/pip'
> > You are using pip version 9.0.1, however version 18.0 is available.
> > You should consider upgrading via the 'pip install --upgrade pip'
> command.
> > user@host$ pip --version
> > pip 9.0.1 from /home/user/.local/lib/python2.7/site-packages (python 2.7)
> > user@host$
> >
> > Sure enough, no change. Given the file permission error, I figured
> > that I needed root privileges, so I tried again:
> >
> > user@host$ sudo pip install --upgrade pip
> > [sudo] password for user:
> > The directory '/home/user/.cache/pip/http' or its parent directory is
> > not owned by the current user and the cache has been disabled. Please
> > check the permissions and owner of that directory. If executing pip with
> > sudo, you may want sudo's -H flag.
> > The directory '/home/user/.cache/pip' or its parent directory is not
> > owned by the current user and caching wheels has been disabled. check
> > the permissions and owner of that directory. If executing pip with sudo,
> > you may want sudo's -H flag.
> > Collecting pip
> >   Downloading
> >
> https://files.pythonhosted.org/packages/5f/25/e52d3f31441505a5f3af41213346e5b6c221c9e086a166f3703d2ddaf940/pip-18.0-py2.py3-none-any.whl
> > (1.3MB)
> > 100% || 1.3MB 442kB/s
> > Installing collected packages: pip
> >   Found existing installation: pip 9.0.1
> > Uninstalling pip-9.0.1:
> >   Successfully uninstalled pip-9.0.1
> > Successfully installed pip-18.0
> > user@host$ pip --version
> > Traceback (most recent call last):
> >   File "/usr/bin/pip", line 9, in 
> > from pip import main
> > ImportError: cannot import name main
> > user@host$
> >
> > Well, even though it said "Successfully installed", it appears to
> > not have done so.
> >
> > Trying again with sudo's -H option:
> >
> > user@host$ sudo -H pip install --upgrade pip
> > Requirement already up-to-date: pip in
> > /usr/local/lib/python2.7/dist-packages (18.0)
> > user@host$ pip --version
> > Traceback (most recent call last):
> >   File "/usr/bin/pip", line 9, in 
> > from pip import main
> > ImportError: cannot import name main
> > user@host$
> >
>
> --
> https://mail.pyth

Re: Broken pip

2018-08-29 Thread Thomas Jollans
On 2018-08-28 20:10, Michael F. Stemper wrote:
> I'm trying to upgrade my pip on Ubuntu 16.04. I appear to have
> buggered things up pretty well. (Details follow) Any suggestions
> on how to undo this and get everything back to proper operation?
> 
> Based on the information that I found at:
> , I did the following:
> 
> user@host$ pip --version
> pip 9.0.1 from /home/user/.local/lib/python2.7/site-packages (python 2.7)

Apparently, you did it the "right" way before: installing anything
system-wide with pip that has already been installed with distribution
packages is fairly likely to break. Installing a newer pip in your home
directory should normally work fine.

Opinions differ, but personally I *never* use "sudo pip": use "pip
install --user" instead. This installs into ~/.local rather than /usr/local.

i.e.: try

  python -m pip install --upgrade --user pip

If that works, see if

  python -m pip --version
and
  pip --version

work and show the same thing. If the latter doesn't work or shows an old
version, you may have to make sure ~/.local/bin/pip has priority over
/usr/bin/pip (e.g. by putting ~/.local/bin/ near the front of your $PATH)

If things break, you now know how to undo the damage thanks to Larry ;-)

Also, PLEASE use Python 3. Still using Python 2 today is like still
using Windows XP in early 2013.

https://pythonclock.org/

-- Thomas


> user@host$ pip install --upgrade pip
> Collecting pip
>   Downloading
> https://files.pythonhosted.org/packages/5f/25/e52d3f31441505a5f3af41213346e5b6c221c9e086a166f3703d2ddaf940/pip-18.0-py2.py3-none-any.whl
> (1.3MB)
> 100% || 1.3MB 453kB/s
> Installing collected packages: pip
>   Found existing installation: pip 9.0.1
> Uninstalling pip-9.0.1:
>   Successfully uninstalled pip-9.0.1
>   Rolling back uninstall of pip
> Exception:
> Traceback (most recent call last):
>  [snip error traceback]
> mkdir(name, mode)
> OSError: [Errno 13] Permission denied:
> '/usr/local/lib/python2.7/dist-packages/pip'
> You are using pip version 9.0.1, however version 18.0 is available.
> You should consider upgrading via the 'pip install --upgrade pip' command.
> user@host$ pip --version
> SError: [Errno 13] Permission denied:
> '/usr/local/lib/python2.7/dist-packages/pip'
> You are using pip version 9.0.1, however version 18.0 is available.
> You should consider upgrading via the 'pip install --upgrade pip' command.
> user@host$ pip --version
> pip 9.0.1 from /home/user/.local/lib/python2.7/site-packages (python 2.7)
> user@host$
> 
> Sure enough, no change. Given the file permission error, I figured
> that I needed root privileges, so I tried again:
> 
> user@host$ sudo pip install --upgrade pip
> [sudo] password for user:
> The directory '/home/user/.cache/pip/http' or its parent directory is
> not owned by the current user and the cache has been disabled. Please
> check the permissions and owner of that directory. If executing pip with
> sudo, you may want sudo's -H flag.
> The directory '/home/user/.cache/pip' or its parent directory is not
> owned by the current user and caching wheels has been disabled. check
> the permissions and owner of that directory. If executing pip with sudo,
> you may want sudo's -H flag.
> Collecting pip
>   Downloading
> https://files.pythonhosted.org/packages/5f/25/e52d3f31441505a5f3af41213346e5b6c221c9e086a166f3703d2ddaf940/pip-18.0-py2.py3-none-any.whl
> (1.3MB)
> 100% || 1.3MB 442kB/s
> Installing collected packages: pip
>   Found existing installation: pip 9.0.1
> Uninstalling pip-9.0.1:
>   Successfully uninstalled pip-9.0.1
> Successfully installed pip-18.0
> user@host$ pip --version
> Traceback (most recent call last):
>   File "/usr/bin/pip", line 9, in 
> from pip import main
> ImportError: cannot import name main
> user@host$
> 
> Well, even though it said "Successfully installed", it appears to
> not have done so.
> 
> Trying again with sudo's -H option:
> 
> user@host$ sudo -H pip install --upgrade pip
> Requirement already up-to-date: pip in
> /usr/local/lib/python2.7/dist-packages (18.0)
> user@host$ pip --version
> Traceback (most recent call last):
>   File "/usr/bin/pip", line 9, in 
> from pip import main
> ImportError: cannot import name main
> user@host$
> 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Broken pip

2018-08-28 Thread Gregory Ewing

Chris Angelico wrote:

On 2018-08-28 13:19, Larry Martell wrote:

source .bashrc

I'm not sure what the point of it is, but
maybe it's ensuring that your $PATH is set correctly.


The installation you just did might have edited your
.bashrc file (to modify PATH etc.), so it ensures that
your current shell is up to date with those changes.

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list


Re: Broken pip

2018-08-28 Thread Michael F. Stemper
On 2018-08-28 13:45, Chris Angelico wrote:
> On Wed, Aug 29, 2018 at 4:37 AM, Michael F. Stemper
>  wrote:
>> On 2018-08-28 13:19, Larry Martell wrote:
>>> On Tue, Aug 28, 2018 at 2:10 PM, Michael F. Stemper
>>>  wrote:

 I'm trying to upgrade my pip on Ubuntu 16.04. I appear to have
 buggered things up pretty well. (Details follow) Any suggestions
 on how to undo this and get everything back to proper operation?
>>
>>> Try doing this:
>>>
>>> sudo python -m pip uninstall pip
>>> sudo apt remove python-pip
>>> sudo apt install python-pip
>>> source .bashrc
>>
>> I'm certainly more comfortable with apt than with pip (probably
>> due to longer experience).
>>
>> What's that last bit, though? From what I can find on-line, it looks as
>> if it would be similar to:
>> . ~/.bashrc
>> but I don't quite understand the point of doing that *after* all of
>> the other stuff.
> 
> The dot is an alias for "source", so it's identical (assuming you're
> in your home directory). I'm not sure what the point of it is, but
> maybe it's ensuring that your $PATH is set correctly.

Well, I proceeded as suggested, and things are no longer broken:
user@host$ pip --version
pip 8.1.1 from /usr/lib/python2.7/dist-packages (python 2.7)
user@host$

(The same output before and after doing the "source .bashrc")

I guess that I'll just ignore the messages that tell me to upgrade
my pip.

Thanks to all!

-- 
Michael F. Stemper
Economists have correctly predicted seven of the last three recessions.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Broken pip

2018-08-28 Thread Chris Angelico
On Wed, Aug 29, 2018 at 4:37 AM, Michael F. Stemper
 wrote:
> On 2018-08-28 13:19, Larry Martell wrote:
>> On Tue, Aug 28, 2018 at 2:10 PM, Michael F. Stemper
>>  wrote:
>>>
>>> I'm trying to upgrade my pip on Ubuntu 16.04. I appear to have
>>> buggered things up pretty well. (Details follow) Any suggestions
>>> on how to undo this and get everything back to proper operation?
>
>> Try doing this:
>>
>> sudo python -m pip uninstall pip
>> sudo apt remove python-pip
>> sudo apt install python-pip
>> source .bashrc
>
> I'm certainly more comfortable with apt than with pip (probably
> due to longer experience).
>
> What's that last bit, though? From what I can find on-line, it looks as
> if it would be similar to:
> . ~/.bashrc
> but I don't quite understand the point of doing that *after* all of
> the other stuff.

The dot is an alias for "source", so it's identical (assuming you're
in your home directory). I'm not sure what the point of it is, but
maybe it's ensuring that your $PATH is set correctly.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Broken pip

2018-08-28 Thread Michael F. Stemper
On 2018-08-28 13:19, Larry Martell wrote:
> On Tue, Aug 28, 2018 at 2:10 PM, Michael F. Stemper
>  wrote:
>>
>> I'm trying to upgrade my pip on Ubuntu 16.04. I appear to have
>> buggered things up pretty well. (Details follow) Any suggestions
>> on how to undo this and get everything back to proper operation?

> Try doing this:
> 
> sudo python -m pip uninstall pip
> sudo apt remove python-pip
> sudo apt install python-pip
> source .bashrc

I'm certainly more comfortable with apt than with pip (probably
due to longer experience).

What's that last bit, though? From what I can find on-line, it looks as
if it would be similar to:
. ~/.bashrc
but I don't quite understand the point of doing that *after* all of
the other stuff.

Thanks for your quick reply.

-- 
Michael F. Stemper
This sentence no verb.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Broken pip

2018-08-28 Thread Larry Martell
On Tue, Aug 28, 2018 at 2:10 PM, Michael F. Stemper
 wrote:
>
> I'm trying to upgrade my pip on Ubuntu 16.04. I appear to have
> buggered things up pretty well. (Details follow) Any suggestions
> on how to undo this and get everything back to proper operation?
>
> Based on the information that I found at:
> , I did the following:
>
> user@host$ pip --version
> pip 9.0.1 from /home/user/.local/lib/python2.7/site-packages (python 2.7)
> user@host$ pip install --upgrade pip
> Collecting pip
>   Downloading
> https://files.pythonhosted.org/packages/5f/25/e52d3f31441505a5f3af41213346e5b6c221c9e086a166f3703d2ddaf940/pip-18.0-py2.py3-none-any.whl
> (1.3MB)
> 100% || 1.3MB 453kB/s
> Installing collected packages: pip
>   Found existing installation: pip 9.0.1
> Uninstalling pip-9.0.1:
>   Successfully uninstalled pip-9.0.1
>   Rolling back uninstall of pip
> Exception:
> Traceback (most recent call last):
>  [snip error traceback]
> mkdir(name, mode)
> OSError: [Errno 13] Permission denied:
> '/usr/local/lib/python2.7/dist-packages/pip'
> You are using pip version 9.0.1, however version 18.0 is available.
> You should consider upgrading via the 'pip install --upgrade pip' command.
> user@host$ pip --version
> SError: [Errno 13] Permission denied:
> '/usr/local/lib/python2.7/dist-packages/pip'
> You are using pip version 9.0.1, however version 18.0 is available.
> You should consider upgrading via the 'pip install --upgrade pip' command.
> user@host$ pip --version
> pip 9.0.1 from /home/user/.local/lib/python2.7/site-packages (python 2.7)
> user@host$
>
> Sure enough, no change. Given the file permission error, I figured
> that I needed root privileges, so I tried again:
>
> user@host$ sudo pip install --upgrade pip
> [sudo] password for user:
> The directory '/home/user/.cache/pip/http' or its parent directory is
> not owned by the current user and the cache has been disabled. Please
> check the permissions and owner of that directory. If executing pip with
> sudo, you may want sudo's -H flag.
> The directory '/home/user/.cache/pip' or its parent directory is not
> owned by the current user and caching wheels has been disabled. check
> the permissions and owner of that directory. If executing pip with sudo,
> you may want sudo's -H flag.
> Collecting pip
>   Downloading
> https://files.pythonhosted.org/packages/5f/25/e52d3f31441505a5f3af41213346e5b6c221c9e086a166f3703d2ddaf940/pip-18.0-py2.py3-none-any.whl
> (1.3MB)
> 100% || 1.3MB 442kB/s
> Installing collected packages: pip
>   Found existing installation: pip 9.0.1
> Uninstalling pip-9.0.1:
>   Successfully uninstalled pip-9.0.1
> Successfully installed pip-18.0
> user@host$ pip --version
> Traceback (most recent call last):
>   File "/usr/bin/pip", line 9, in 
> from pip import main
> ImportError: cannot import name main
> user@host$
>
> Well, even though it said "Successfully installed", it appears to
> not have done so.
>
> Trying again with sudo's -H option:
>
> user@host$ sudo -H pip install --upgrade pip
> Requirement already up-to-date: pip in
> /usr/local/lib/python2.7/dist-packages (18.0)
> user@host$ pip --version
> Traceback (most recent call last):
>   File "/usr/bin/pip", line 9, in 
> from pip import main
> ImportError: cannot import name main
> user@host$

Try doing this:

sudo python -m pip uninstall pip
sudo apt remove python-pip
sudo apt install python-pip
source .bashrc
-- 
https://mail.python.org/mailman/listinfo/python-list


Broken pip

2018-08-28 Thread Michael F. Stemper
I'm trying to upgrade my pip on Ubuntu 16.04. I appear to have
buggered things up pretty well. (Details follow) Any suggestions
on how to undo this and get everything back to proper operation?

Based on the information that I found at:
, I did the following:

user@host$ pip --version
pip 9.0.1 from /home/user/.local/lib/python2.7/site-packages (python 2.7)
user@host$ pip install --upgrade pip
Collecting pip
  Downloading
https://files.pythonhosted.org/packages/5f/25/e52d3f31441505a5f3af41213346e5b6c221c9e086a166f3703d2ddaf940/pip-18.0-py2.py3-none-any.whl
(1.3MB)
100% || 1.3MB 453kB/s
Installing collected packages: pip
  Found existing installation: pip 9.0.1
Uninstalling pip-9.0.1:
  Successfully uninstalled pip-9.0.1
  Rolling back uninstall of pip
Exception:
Traceback (most recent call last):
 [snip error traceback]
mkdir(name, mode)
OSError: [Errno 13] Permission denied:
'/usr/local/lib/python2.7/dist-packages/pip'
You are using pip version 9.0.1, however version 18.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
user@host$ pip --version
SError: [Errno 13] Permission denied:
'/usr/local/lib/python2.7/dist-packages/pip'
You are using pip version 9.0.1, however version 18.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
user@host$ pip --version
pip 9.0.1 from /home/user/.local/lib/python2.7/site-packages (python 2.7)
user@host$

Sure enough, no change. Given the file permission error, I figured
that I needed root privileges, so I tried again:

user@host$ sudo pip install --upgrade pip
[sudo] password for user:
The directory '/home/user/.cache/pip/http' or its parent directory is
not owned by the current user and the cache has been disabled. Please
check the permissions and owner of that directory. If executing pip with
sudo, you may want sudo's -H flag.
The directory '/home/user/.cache/pip' or its parent directory is not
owned by the current user and caching wheels has been disabled. check
the permissions and owner of that directory. If executing pip with sudo,
you may want sudo's -H flag.
Collecting pip
  Downloading
https://files.pythonhosted.org/packages/5f/25/e52d3f31441505a5f3af41213346e5b6c221c9e086a166f3703d2ddaf940/pip-18.0-py2.py3-none-any.whl
(1.3MB)
100% || 1.3MB 442kB/s
Installing collected packages: pip
  Found existing installation: pip 9.0.1
Uninstalling pip-9.0.1:
  Successfully uninstalled pip-9.0.1
Successfully installed pip-18.0
user@host$ pip --version
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in 
from pip import main
ImportError: cannot import name main
user@host$

Well, even though it said "Successfully installed", it appears to
not have done so.

Trying again with sudo's -H option:

user@host$ sudo -H pip install --upgrade pip
Requirement already up-to-date: pip in
/usr/local/lib/python2.7/dist-packages (18.0)
user@host$ pip --version
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in 
from pip import main
ImportError: cannot import name main
user@host$

-- 
Michael F. Stemper
Galatians 3:28
-- 
https://mail.python.org/mailman/listinfo/python-list