安装tensorflow遇到无法卸载numpy 1.1.3的问题

本文记录了在Mac上使用pip安装TensorFlow时遇到的问题及解决办法。安装过程中因权限问题导致失败,通过添加参数解决了卸载旧依赖的问题,并最终成功安装。
部署运行你感兴趣的模型镜像

最近在关注 Deep Learning,就在自己的mac上安装google的开源框架Tensorflow 
用 sudo pip install -U tensorflow 
安装的时候总是遇到下面的问题:

sudo pip install -U tensorflow
Password:
The directory '/Users/jason/Library/Caches/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 '/Users/jason/Library/Caches/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 tensorflow
  Downloading tensorflow-1.0.0-cp27-cp27m-macosx_10_11_x86_64.whl (39.3MB)
100% |████████████████████████████████| 39.4MB 32kB/s 
Collecting numpy>=1.11.0 (from tensorflow)
  Downloading numpy-1.12.0-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (4.4MB)
100% |████████████████████████████████| 4.4MB 195kB/s 
Requirement already up-to-date: six>=1.10.0 in /Library/Python/2.7/site-packages/six-1.10.0-py2.7.egg (from tensorflow)
Requirement already up-to-date: mock>=2.0.0 in /Library/Python/2.7/site-packages (from tensorflow)
Requirement already up-to-date: wheel in /Library/Python/2.7/site-packages (from tensorflow)
Requirement already up-to-date: protobuf>=3.1.0 in /Library/Python/2.7/site-packages (from tensorflow)
Requirement already up-to-date: funcsigs>=1; python_version < "3.3" in /Library/Python/2.7/site-packages (from mock>=2.0.0->tensorflow)
Requirement already up-to-date: pbr>=0.11 in /Library/Python/2.7/site-packages (from mock>=2.0.0->tensorflow)
Collecting setuptools (from protobuf>=3.1.0->tensorflow)
  Downloading setuptools-34.3.0-py2.py3-none-any.whl (389kB)
100% |████████████████████████████████| 399kB 1.1MB/s 
Requirement already up-to-date: packaging>=16.8 in /Library/Python/2.7/site-packages (from setuptools->protobuf>=3.1.0->tensorflow)
Requirement already up-to-date: appdirs>=1.4.0 in /Library/Python/2.7/site-packages (from setuptools->protobuf>=3.1.0->tensorflow)
Collecting pyparsing (from packaging>=16.8->setuptools->protobuf>=3.1.0->tensorflow)
  Downloading pyparsing-2.1.10-py2.py3-none-any.whl (56kB)
100% |████████████████████████████████| 61kB 2.5MB/s 
Installing collected packages: numpy, tensorflow, setuptools, pyparsing
  Found existing installation: numpy 1.8.0rc1
DEPRECATION: Uninstalling a distutils installed project (numpy) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
Uninstalling numpy-1.8.0rc1:
Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 215, in main
status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py", line 342, in run
prefix=options.prefix_path,
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py", line 778, in install
requirement.uninstall(auto_confirm=True)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 754, in uninstall
paths_to_remove.remove(auto_confirm)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_uninstall.py", line 115, in remove
renames(path, new_path)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/utils/__init__.py", line 267, in renames
shutil.move(old, new)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 302, in move
copy2(src, real_dst)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 131, in copy2
copystat(src, dst)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 103, in copystat
os.chflags(dst, st.st_flags)
OSError: [Errno 1] Operation not permitted: '/tmp/pip-aGEdP5-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy-1.8.0rc1-py2.7.egg-info'

后来google到 需要在命令后面加上 –-ignore-installed six 
就成功了,不过知其然,而不知其所以然

localhost:Desktop jasonlee$ sudo -H pip install tensorflow --ignore-installed six
The directory '/Users/jason/Library/Caches/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 '/Users/jason/Library/Caches/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 tensorflow
  Downloading tensorflow-1.0.0-cp27-cp27m-macosx_10_11_x86_64.whl (39.3MB)
100% |████████████████████████████████| 39.4MB 29kB/s 
Collecting six
  Downloading six-1.10.0-py2.py3-none-any.whl
Collecting numpy>=1.11.0 (from tensorflow)
  Downloading numpy-1.12.0-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (4.4MB)
100% |████████████████████████████████| 4.4MB 210kB/s 
Collecting mock>=2.0.0 (from tensorflow)
  Downloading mock-2.0.0-py2.py3-none-any.whl (56kB)
100% |████████████████████████████████| 61kB 556kB/s 
Collecting wheel (from tensorflow)
  Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB)
100% |████████████████████████████████| 71kB 586kB/s 
Collecting protobuf>=3.1.0 (from tensorflow)
  Downloading protobuf-3.2.0-py2.py3-none-any.whl (360kB)
100% |████████████████████████████████| 368kB 922kB/s 
Collecting funcsigs>=1; python_version < "3.3" (from mock>=2.0.0->tensorflow)
  Downloading funcsigs-1.0.2-py2.py3-none-any.whl
Collecting pbr>=0.11 (from mock>=2.0.0->tensorflow)
  Downloading pbr-1.10.0-py2.py3-none-any.whl (96kB)
100% |████████████████████████████████| 102kB 1.1MB/s 
Collecting setuptools (from protobuf>=3.1.0->tensorflow)
  Downloading setuptools-34.3.0-py2.py3-none-any.whl (389kB)
100% |████████████████████████████████| 399kB 657kB/s 
Collecting packaging>=16.8 (from setuptools->protobuf>=3.1.0->tensorflow)
  Downloading packaging-16.8-py2.py3-none-any.whl
Collecting appdirs>=1.4.0 (from setuptools->protobuf>=3.1.0->tensorflow)
  Downloading appdirs-1.4.2-py2.py3-none-any.whl
Collecting pyparsing (from packaging>=16.8->setuptools->protobuf>=3.1.0->tensorflow)
  Downloading pyparsing-2.1.10-py2.py3-none-any.whl (56kB)
100% |████████████████████████████████| 61kB 1.0MB/s 
Installing collected packages: numpy, funcsigs, six, pbr, mock, wheel, pyparsing, packaging, appdirs, setuptools, protobuf, tensorflow
Successfully installed appdirs-1.4.2 funcsigs-1.0.2 mock-2.0.0 numpy-1.12.0 packaging

您可能感兴趣的与本文相关的镜像

TensorFlow-v2.15

TensorFlow-v2.15

TensorFlow

TensorFlow 是由Google Brain 团队开发的开源机器学习框架,广泛应用于深度学习研究和生产环境。 它提供了一个灵活的平台,用于构建和训练各种机器学习模型

升级numpy后(没有报错),进行检查thinc是否正常工作的时候出现下面的错误,请你帮我分析一下怎么解决 ERROR: pip&#39;s dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. bigframes 2.12.0 requires google-cloud-bigquery-storage<3.0.0,>=2.30.0, which is not installed. trl 0.9.6 requires numpy<2.0.0,>=1.18.2, but you have numpy 2.3.4 which is incompatible. mkl-umath 0.1.1 requires numpy<1.27.0,>=1.26.4, but you have numpy 2.3.4 which is incompatible. mkl-random 1.2.4 requires numpy<1.27.0,>=1.26.4, but you have numpy 2.3.4 which is incompatible. mkl-fft 1.3.8 requires numpy<1.27.0,>=1.26.4, but you have numpy 2.3.4 which is incompatible. numba 0.60.0 requires numpy<2.1,>=1.22, but you have numpy 2.3.4 which is incompatible. ydata-profiling 4.17.0 requires numpy<2.2,>=1.16.0, but you have numpy 2.3.4 which is incompatible. s3fs 2025.3.0 requires fsspec==2025.3.0.*, but you have fsspec 2024.6.1 which is incompatible. ray 2.51.1 requires click!=8.3.0,>=7.0, but you have click 8.3.0 which is incompatible. google-colab 1.0.0 requires notebook==6.5.7, but you have notebook 6.5.4 which is incompatible. google-colab 1.0.0 requires pandas==2.2.2, but you have pandas 2.2.3 which is incompatible. google-colab 1.0.0 requires requests==2.32.3, but you have requests 2.32.5 which is incompatible. google-colab 1.0.0 requires tornado==6.4.2, but you have tornado 6.5.2 which is incompatible. dopamine-rl 4.1.2 requires gymnasium>=1.0.0, but you have gymnasium 0.29.0 which is incompatible. bigframes 2.12.0 requires rich<14,>=12.4.4, but you have rich 14.2.0 which is incompatible. ibis-framework 9.5.0 requires toolz<1,>=0.11, but you have toolz 1.1.0 which is incompatible. opencv-contrib-python 4.12.0.88 requires numpy<2.3.0,>=2; python_version >= "3.9", but you have numpy 2.3.4 which is incompatible. opencv-python 4.12.0.88 requires numpy<2.3.0,>=2; python_version >= "3.9", but you have numpy 2.3.4 which is incompatible. gradio 5.38.1 requires pydantic<2.12,>=2.0, but you have pydantic 2.12.4 which is incompatible. cudf-polars-cu12 25.6.0 requires pylibcudf-cu12==25.6.*, but you have pylibcudf-cu12 25.2.2 which is incompatible. pydrive2 1.21.3 requires cryptography<44, but you have cryptography 46.0.3 which is incompatible. pydrive2 1.21.3 requires pyOpenSSL<=24.2.1,>=19.1.0, but you have pyopenssl 25.3.0 which is incompatible. imbalanced-learn 0.13.0 requires scikit-learn<2,>=1.3.2, but you have scikit-learn 1.2.2 which is incompatible. opencv-python-headless 4.12.0.88 requires numpy<2.3.0,>=2; python_version >= "3.9", but you have numpy 2.3.4 which is incompatible. plotnine 0.14.5 requires matplotlib>=3.8.0, but you have matplotlib 3.7.2 which is incompatible. tensorflow 2.18.0 requires numpy<2.1.0,>=1.26.0, but you have numpy 2.3.4 which is incompatible. tensorflow 2.18.0 requires protobuf!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<6.0.0dev,>=3.20.3, but you have protobuf 6.33.0 which is incompatible. pylibcugraph-cu12 25.6.0 requires pylibraft-cu12==25.6.*, but you have pylibraft-cu12 25.2.0 which is incompatible. pylibcugraph-cu12 25.6.0 requires rmm-cu12==25.6.*, but you have rmm-cu12 25.2.0 which is incompatible. umap-learn 0.5.9.post2 requires scikit-learn>=1.6, but you have scikit-learn 1.2.2 which is incompatible. gcsfs 2025.3.0 requires fsspec==2025.3.0, but you have fsspec 2024.6.1 which is incompatible. mlxtend 0.23.4 requires scikit-learn>=1.3.1, but you have scikit-learn 1.2.2 which is incompatible. Successfully installed annotated-types-0.7.0 blis-1.3.2 catalogue-2.0.10 confection-0.1.5 cymem-2.0.13 murmurhash-1.0.15 numpy-2.3.4 packaging-25.0 preshed-3.0.11 pydantic-2.12.4 pydantic-core-2.41.5 setuptools-80.9.0 srsly-2.5.1 thinc-8.3.6 typing-extensions-4.15.0 typing-inspection-0.4.2 wasabi-1.1.3
最新发布
11-17
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值