在克隆的 conda 环境中安装 tensorflow 会破坏从中克隆的 conda 环境
Installing tensorflow in cloned conda environment breaks conda environment it was cloned from
我刚刚克隆了一个工作的 miniconda 环境 carnd-term1-gpu
,它有 tensorflow 和 gpu,使用 tensorflow 版本“0.12.1”。该环境安装了许多其他 python 包。我想升级到最新版本的tensorflow所以我做了以下基于tensorflow Ubuntu:
1) 将现有工作环境克隆为 tflow
conda create --name tflow --clone carnd-term1-gpu
这已成功完成。
2) source activate tflow and install using pip
source activate tflow
(tflow) xx@pc:~$ pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.1.0-cp35-cp35m-linux_x86_64.whl
现在我尝试运行旧的环境假设它不应该被改变。
source activate carnd-term1-gpu
ipython
然后在 ipython 提示符下键入 import numpy as np
并得到以下内容:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-4ee716103900> in <module>()
----> 1 import numpy as np
/home/ai/miniconda3/envs/carnd-term1-gpu/lib/python3.5/site-packages/numpy/__init__.py in <module>()
140 return loader(*packages, **options)
141
--> 142 from . import add_newdocs
143 __all__ = ['add_newdocs',
144 'ModuleDeprecationWarning',
/home/ai/miniconda3/envs/carnd-term1-gpu/lib/python3.5/site-packages/numpy/add_newdocs.py in <module>()
11 from __future__ import division, absolute_import, print_function
12
---> 13 from numpy.lib import add_newdoc
14
15 ###############################################################################
/home/ai/miniconda3/envs/carnd-term1-gpu/lib/python3.5/site-packages/numpy/lib/__init__.py in <module>()
6 from numpy.version import version as __version__
7
----> 8 from .type_check import *
9 from .index_tricks import *
10 from .function_base import *
/home/ai/miniconda3/envs/carnd-term1-gpu/lib/python3.5/site-packages/numpy/lib/type_check.py in <module>()
9 'common_type']
10
---> 11 import numpy.core.numeric as _nx
12 from numpy.core.numeric import asarray, asanyarray, array, isnan, \
13 obj2sctype, zeros
/home/ai/miniconda3/envs/carnd-term1-gpu/lib/python3.5/site-packages/numpy/core/__init__.py in <module>()
51 from . import shape_base
52 from .shape_base import *
---> 53 from . import einsumfunc
54 from .einsumfunc import *
55 del nt
ImportError: cannot import name 'einsumfunc'
我以为我通过克隆一个单独的环境并仅更改该环境而受到保护,但是似乎一个环境中的安装改变了另一个环境中的行为。正是我以为我在避免的东西!出了什么问题,我该如何解决?到目前为止,新环境似乎运行良好。
我检查了两种环境中的文件日期。 carnd-term1-gpu
环境中的文件日期与我在 tflow
环境中进行升级的同一天。关于如何实现的任何想法?
我尝试将丢失的文件 einsumfunc.py
添加到我的 carnd-term1-gpu
环境并再次启动 Ipython。这次当我执行 import numpy as np
时,无法导入不同的文件。所以看起来我的 carnd-term1-gpu
环境已损坏。
比较每个环境的 conda list
并仅查看 numpy
,我看到以下内容:
对于 tflow
环境:
numpy 1.11.3 <pip>
numpy 1.12.1 <pip>
numpy 1.11.3 py35_blas_openblas_200 [blas_openblas] conda-forge
并且对于 carnd-term1-gpu
环境:
numpy 1.11.3 <pip>
numpy 1.11.3 py35_blas_openblas_200 [blas_openblas] conda-forge
然后我使用 conda list --revisions
查看了修订。两种环境都只显示 rev 0
的单个修订版。同样,查看 conda-meta/history
仅显示 carnd-term1-gpu
的 1 月 13 日和 tflow
的 5 月 9 日的原始创建日期。所以这个版本pip的组合:
pip 9.0.1 py35_0 conda-forge
结合这个轮子:
https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.1.0-cp35-cp35m-linux_x86_64.whl
以某种方式破坏了环境 carnd-term1-gpu
。这似乎是一个错误,或者我以某种方式从 tensorflow 站点得到了一个损坏的轮子?如果是后者,它怎么会破坏与安装环境不同的环境呢?
注意 pip 的版本在两种环境中都是相同的。
我执行了以下操作来调查在我进行安装的那一天更改了哪些文件。
find /home/ai/miniconda3/envs/carnd-term1-gpu/ -type f -newermt 2017-05-09 -ls | wc -l
这表明有 669 个文件是 created/modified。其中大部分在 /site-packages/numpy/
,但 six.py
、pyparsing.py
、/setuptools/
、/pkg_resources/
、easy_install.py
、/werkzeug/
也受到影响.
conda --version
是 4.2.12
我尝试了以下方法让我的旧环境再次运行。
conda env export > environment.yml
conda env create -f environment.yml -n sdc-gpu
这导致了以下错误:
Could not import setuptools which is required to install from a source distribution.
Traceback (most recent call last):
File "/home/ai/miniconda3/envs/sdc-gpu/lib/python3.5/site-packages/pip/req/req_install.py", line 387, in setup_py
import setuptools # noqa
File "/home/ai/miniconda3/envs/sdc-gpu/lib/python3.5/site-packages/setuptools/__init__.py", line 12, in <module>
import setuptools.version
File "/home/ai/miniconda3/envs/sdc-gpu/lib/python3.5/site-packages/setuptools/version.py", line 1, in <module>
import pkg_resources
File "/home/ai/miniconda3/envs/sdc-gpu/lib/python3.5/site-packages/pkg_resources/__init__.py", line 70, in <module>
import packaging.version
ImportError: No module named 'packaging'
CondaValueError: Value error: pip returned an error.
我刚从 continuum 那里得到以下信息;
"To keep this from happening, you'll have to use the --copy
flag with your clone operation. Core to conda's design is extensive use of hard links. This exact issue is one of the biggest pitfalls."
因此,如果我在第一次克隆环境时执行以下操作,我就可以避免破坏旧环境:
conda create --name tflow --copy --clone carnd-term1-gpu
选项 --copy Install all packages using copies instead of hard- or soft-link‐ing
将阻止 pip 覆盖文件。
有关此问题以及将来如何解决的一些正在进行的讨论在此处:conda pip breaks
我唯一的恢复选择是重新安装每个损坏的包。将 pip 与 conda 一起使用时要小心...
我刚刚克隆了一个工作的 miniconda 环境 carnd-term1-gpu
,它有 tensorflow 和 gpu,使用 tensorflow 版本“0.12.1”。该环境安装了许多其他 python 包。我想升级到最新版本的tensorflow所以我做了以下基于tensorflow Ubuntu:
1) 将现有工作环境克隆为 tflow
conda create --name tflow --clone carnd-term1-gpu
这已成功完成。
2) source activate tflow and install using pip
source activate tflow
(tflow) xx@pc:~$ pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.1.0-cp35-cp35m-linux_x86_64.whl
现在我尝试运行旧的环境假设它不应该被改变。
source activate carnd-term1-gpu
ipython
然后在 ipython 提示符下键入 import numpy as np
并得到以下内容:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-4ee716103900> in <module>()
----> 1 import numpy as np
/home/ai/miniconda3/envs/carnd-term1-gpu/lib/python3.5/site-packages/numpy/__init__.py in <module>()
140 return loader(*packages, **options)
141
--> 142 from . import add_newdocs
143 __all__ = ['add_newdocs',
144 'ModuleDeprecationWarning',
/home/ai/miniconda3/envs/carnd-term1-gpu/lib/python3.5/site-packages/numpy/add_newdocs.py in <module>()
11 from __future__ import division, absolute_import, print_function
12
---> 13 from numpy.lib import add_newdoc
14
15 ###############################################################################
/home/ai/miniconda3/envs/carnd-term1-gpu/lib/python3.5/site-packages/numpy/lib/__init__.py in <module>()
6 from numpy.version import version as __version__
7
----> 8 from .type_check import *
9 from .index_tricks import *
10 from .function_base import *
/home/ai/miniconda3/envs/carnd-term1-gpu/lib/python3.5/site-packages/numpy/lib/type_check.py in <module>()
9 'common_type']
10
---> 11 import numpy.core.numeric as _nx
12 from numpy.core.numeric import asarray, asanyarray, array, isnan, \
13 obj2sctype, zeros
/home/ai/miniconda3/envs/carnd-term1-gpu/lib/python3.5/site-packages/numpy/core/__init__.py in <module>()
51 from . import shape_base
52 from .shape_base import *
---> 53 from . import einsumfunc
54 from .einsumfunc import *
55 del nt
ImportError: cannot import name 'einsumfunc'
我以为我通过克隆一个单独的环境并仅更改该环境而受到保护,但是似乎一个环境中的安装改变了另一个环境中的行为。正是我以为我在避免的东西!出了什么问题,我该如何解决?到目前为止,新环境似乎运行良好。
我检查了两种环境中的文件日期。 carnd-term1-gpu
环境中的文件日期与我在 tflow
环境中进行升级的同一天。关于如何实现的任何想法?
我尝试将丢失的文件 einsumfunc.py
添加到我的 carnd-term1-gpu
环境并再次启动 Ipython。这次当我执行 import numpy as np
时,无法导入不同的文件。所以看起来我的 carnd-term1-gpu
环境已损坏。
比较每个环境的 conda list
并仅查看 numpy
,我看到以下内容:
对于 tflow
环境:
numpy 1.11.3 <pip>
numpy 1.12.1 <pip>
numpy 1.11.3 py35_blas_openblas_200 [blas_openblas] conda-forge
并且对于 carnd-term1-gpu
环境:
numpy 1.11.3 <pip>
numpy 1.11.3 py35_blas_openblas_200 [blas_openblas] conda-forge
然后我使用 conda list --revisions
查看了修订。两种环境都只显示 rev 0
的单个修订版。同样,查看 conda-meta/history
仅显示 carnd-term1-gpu
的 1 月 13 日和 tflow
的 5 月 9 日的原始创建日期。所以这个版本pip的组合:
pip 9.0.1 py35_0 conda-forge
结合这个轮子:
https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.1.0-cp35-cp35m-linux_x86_64.whl
以某种方式破坏了环境 carnd-term1-gpu
。这似乎是一个错误,或者我以某种方式从 tensorflow 站点得到了一个损坏的轮子?如果是后者,它怎么会破坏与安装环境不同的环境呢?
注意 pip 的版本在两种环境中都是相同的。
我执行了以下操作来调查在我进行安装的那一天更改了哪些文件。
find /home/ai/miniconda3/envs/carnd-term1-gpu/ -type f -newermt 2017-05-09 -ls | wc -l
这表明有 669 个文件是 created/modified。其中大部分在 /site-packages/numpy/
,但 six.py
、pyparsing.py
、/setuptools/
、/pkg_resources/
、easy_install.py
、/werkzeug/
也受到影响.
conda --version
是 4.2.12
我尝试了以下方法让我的旧环境再次运行。
conda env export > environment.yml
conda env create -f environment.yml -n sdc-gpu
这导致了以下错误:
Could not import setuptools which is required to install from a source distribution.
Traceback (most recent call last):
File "/home/ai/miniconda3/envs/sdc-gpu/lib/python3.5/site-packages/pip/req/req_install.py", line 387, in setup_py
import setuptools # noqa
File "/home/ai/miniconda3/envs/sdc-gpu/lib/python3.5/site-packages/setuptools/__init__.py", line 12, in <module>
import setuptools.version
File "/home/ai/miniconda3/envs/sdc-gpu/lib/python3.5/site-packages/setuptools/version.py", line 1, in <module>
import pkg_resources
File "/home/ai/miniconda3/envs/sdc-gpu/lib/python3.5/site-packages/pkg_resources/__init__.py", line 70, in <module>
import packaging.version
ImportError: No module named 'packaging'
CondaValueError: Value error: pip returned an error.
我刚从 continuum 那里得到以下信息;
"To keep this from happening, you'll have to use the --copy
flag with your clone operation. Core to conda's design is extensive use of hard links. This exact issue is one of the biggest pitfalls."
因此,如果我在第一次克隆环境时执行以下操作,我就可以避免破坏旧环境:
conda create --name tflow --copy --clone carnd-term1-gpu
选项 --copy Install all packages using copies instead of hard- or soft-link‐ing
将阻止 pip 覆盖文件。
有关此问题以及将来如何解决的一些正在进行的讨论在此处:conda pip breaks
我唯一的恢复选择是重新安装每个损坏的包。将 pip 与 conda 一起使用时要小心...