最新的Python环境最佳做法:Linux和Windows下的Virtualenv vs Pipenv vs Conda环境

时间:2019-07-17 10:22:13

标签: python linux virtualenv conda pipenv

(我特别感谢那些给这个问题打消分的人,如果可能的话,解释了他们的观点)

我在Ubuntu 19.04下使用python 3.7进行工作。 我的工作不是系统管理。

我必须安装并使用

  • python 3.7
  • jupyter
  • numpy scipy熊猫matplotlib scikit-learn scikit-image张量流

如果我检查已经安装了哪些python版本,我会看到 (https://askubuntu.com/questions/505081/what-version-of-python-do-i-have):

(base)$ sudo find / -type f -executable -iname 'python*' -exec file -i '{}' \; | awk -F: '/x-executable; charset=binary/ {print $1}' | xargs readlink -f | sort -u | xargs -I % sh -c 'echo -n "%: "; % -V'

find: ‘/run/user/1000/doc’: Permission denied
find: ‘/run/user/1000/gvfs’: Permission denied
/snap/core18/1055/usr/bin/python3.6: Python 3.6.8
/snap/core18/1055/usr/bin/python3.6m: Python 3.6.8
/snap/core18/1066/usr/bin/python3.6: Python 3.6.8
/snap/core18/1066/usr/bin/python3.6m: Python 3.6.8
/snap/core/7169/usr/bin/python3.5: Python 3.5.2
/snap/core/7169/usr/bin/python3.5m: Python 3.5.2
/snap/core/7270/usr/bin/python3.5: Python 3.5.2
/snap/core/7270/usr/bin/python3.5m: Python 3.5.2
/snap/gnome-3-28-1804/63/usr/bin/python3.6: Python 3.6.8
/snap/gnome-3-28-1804/63/usr/bin/python3.6m: Python 3.6.8
/snap/gnome-3-28-1804/67/usr/bin/python3.6: Python 3.6.8
/snap/gnome-3-28-1804/67/usr/bin/python3.6m: Python 3.6.8
/usr/bin/python3.7: Python 3.7.3
/usr/bin/python3.7m: Python 3.7.3

# On top of that:

$ conda config --set auto_activate_base False
# close terminal, open a new terminal:

$ python -V
Python 2.7.16
$ which python
/usr/bin/python
$ pip -V
bash: pip: command not found

$ python2 -V
Python 2.7.16
$ which python2
/usr/bin/python2

$ python3 -V
Python 3.7.3
$ which python3
/usr/bin/python3
$ pip3 -V
bash: pip3: command not found


$ conda config --set auto_activate_base True
# close terminal, open a new terminal:

(base)$ python -V
Python 3.7.3
(base)$ which python
/home/yus/anaconda3/bin/python
(base)$ pip -V
pip 19.1.1 from /home/yus/anaconda3/lib/python3.7/site-packages/pip (python 3.7)
(base)$ which pip
/home/yus/anaconda3/bin/pip

(base)$ python2 -V
Python 2.7.16
$ which python2
/usr/bin/python2

(base)$ python3 -V
Python 3.7.3
$ which python3
/home/yus/anaconda3/bin/python3
(base)$ pip3 -V
pip 19.1.1 from /home/yus/anaconda3/lib/python3.7/site-packages/pip (python 3.7)
(base)$ which pip3
/home/yus/anaconda3/bin/pip3

也就是说,已经有4个Python版本没有安装任何特殊功能 为此,我可能确实需要对环境进行封装: Python 2.7.16,Python 3.5.2,Python 3.6.8,Python 3.7.3

  • Ubuntu桌面需要Python 2.7.16
  • Snap(核心和gnome)需要Python 3.5.2和Python 3.6.8
  • Ubuntu 10.4和Conda 4.6随附Python 3.7

对我来说,这一切看起来像是大毕达索斯小姐。

我应该能够使用3种适用于python的环境来管理任何其他python软件包: (https://medium.com/@krishnaregmi/pipenv-vs-virtualenv-vs-conda-environment-3dde3f6869ed

  • Virtualenv
  • Pipenv
  • Conda环境

请为在一个操作系统(在Linux和/或Windows上)上一起使用Python Virtualenv,Pipenv,Conda环境的最佳实践提供建议。请不要发布任何只提及两种环境的内容(因为已经有很多帖子可以轻松搜索)。

谢谢。

0 个答案:

没有答案