Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
199 views
in Technique[技术] by (71.8m points)

python - Can you configure a different logfile for pip2 and pip3, yes/no? if yes, how?

I still have legacy python code to support. But I am also doing some python3 development.

I have pip configured with config file:

[global]
log = /home/USER_NAME/.local/pip/pip.log
format = columns

The problem is that pip2 and pip3 both use the same log file.

Can you configure a different logfile for pip2 and pip3, yes/no? if yes, how?

p.s. if there were an option to specify the config file i could just have an alias for pip2, pip3 where the alias has the different config files but alas I did not see any pip option for specifying the config file.

p.p.s. all my pip install commands are "--user" (i am against sudo pip install usually/generally).


Here's a workaround:

Create a new script pip2 and pip3 and put it on your path ahead of pip2 and pip3. These scripts will at least show what parts of the log file are generated by pip2 and pip3.

pip2 script:

#!/bin/bash
echo "[$(date +'%Y-%m-%d_%H-%M-%S')]: pip2" $@ >> ~/.local/pip/pip.log
python2 -m pip $@

pip3 script:

#!/bin/bash
echo "[$(date +'%Y-%m-%d_%H-%M-%S')]: pip3" $@ >> ~/.local/pip/pip.log
python3 -m pip $@
question from:https://stackoverflow.com/questions/66053096/can-you-configure-a-different-logfile-for-pip2-and-pip3-yes-no-if-yes-how

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...