问题一 pip3 install tensorflow -t pathoname
如果出现下面问题
File "/usr/local/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/local/lib/python2.7/site-packages/pip/commands/install.py", line 342, in run
prefix=options.prefix_path,
File "/usr/local/lib/python2.7/site-packages/pip/req/req_set.py", line 784, in install
**kwargs
File "/usr/local/lib/python2.7/site-packages/pip/req/req_install.py", line 851, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/usr/local/lib/python2.7/site-packages/pip/req/req_install.py", line 1064, in move_wheel_files
isolated=self.isolated,
File "/usr/local/lib/python2.7/site-packages/pip/wheel.py", line 247, in move_wheel_files
prefix=prefix,
File "/usr/local/lib/python2.7/site-packages/pip/locations.py", line 153, in distutils_scheme
i.finalize_options()
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/install.py", line 264, in finalize_options
"must supply either home or prefix/exec-prefix -- not both"
DistutilsOptionError: must supply either home or prefix/exec-prefix -- not both
解决方案
$ echo "[install]
prefix=" > ~/.pydistutils.cfg
问题2 import 问题,如果你安装指定了目录可能会出现以下问题
Traceback (most recent call last):
File "first.py", line 1, in <module>
import tensorflow as tf
ModuleNotFoundError: No module named 'tensorflow'
这里就需要配置下rc文件,根据实际情况可能 rc文件不一样
通用的是 .bashrc ,.zshrc 等等
添加以下代码就可以正常
export PYTHONPATH=/Users/ibeeger/Documents/pyproject/tensorflow:$PYTHONPATH
。。。
待补充