我遇到了多版本python的特殊问题,如2.7和3.4。
python2.7是由apple自己安装的,我自己安装了3.4并且工作得很好
当我使用pip安装sklearn系列(scikit-learn numpy scipy)时,因为这个pip绑定到了python3.4所以python2.7无法使用它,这次我的项目需要2.7。
我不打算卸载3.4。
sh-3.2# python
Python 2.7.10 (default, Oct 23 2015, 18:05:06)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
这意味着我的默认版本的python是2.7
我的问题是当我使用pip install
&只需用pip卸载,python3.4中的附加工作正常。
并安装numpy和scipy到python2.7我下载这些包并找到那些setup.py并使用sudo python setup.py install运行它们。
numpy似乎很好,但scipy有这个麻烦
error: Command "/usr/local/bin/gfortran -Wall -g -ffixed-form -fno-second-underscore -arch x86_64 -fPIC -I/Library/Python/2.7/site-packages/numpy-1.12.0.dev0_d69c147-py2.7-macosx-10.11-intel.egg/numpy/core/include -c -c scipy/integrate/mach/d1mach.f -o build/temp.macosx-10.11-intel-2.7/scipy/integrate/mach/d1mach.o" failed with exit status 1
我执行此操作" sudo python setup.py install
"当scaty我没有gfortran(当然我失败了,发现我需要一个)。并且在得到gfortran我坚持这个恼人的错误。
我的计划是首先卸载scipy,但我不能面对这个
$ pip2.7 uninstall scipy
DEPRECATION: Uninstalling a distutils installed project (scipy) 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 scipy-0.13.0b1:
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/scipy-0.13.0b1-py2.7.egg-info
Proceed (y/n)? y
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip/commands/uninstall.py", line 76, in run
requirement_set.uninstall(auto_confirm=options.yes)
File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 336, in uninstall
req.uninstall(auto_confirm=auto_confirm)
File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 742, in uninstall
paths_to_remove.remove(auto_confirm)
File "/Library/Python/2.7/site-packages/pip/req/req_uninstall.py", line 115, in remove
renames(path, new_path)
File "/Library/Python/2.7/site-packages/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: '/var/folders/8k/7_gm8zxx0zlg0nx4r5dg4rz00000gn/T/pip-hA6VUE-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/scipy-0.13.0b1-py2.7.egg-info'
我非常沮丧但仍在努力。并寻求帮助。
我不是英语发言人。对不起我的英语很差。
更新:刚刚解决了这个问题,我已经解决了所有其他问题,如熊猫或sklearn
sudo pip2.7 install numpy --upgrade
The directory '/Users/ink/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/ink/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 numpy
Downloading numpy-1.11.0-cp27-cp27m-<br>macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (3.9MB)
100% |████████████████████████████████| 3.9MB 275kB/s
Installing collected packages: numpy
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/basecommand.py", line 215, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 317, in run
prefix=options.prefix_path,
File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 736, in install
requirement.uninstall(auto_confirm=True)
File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 742, in uninstall
paths_to_remove.remove(auto_confirm)
File "/Library/Python/2.7/site-packages/pip/req/req_uninstall.py", line 115, in remove
renames(path, new_path)
File "/Library/Python/2.7/site-packages/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-gJ8Ao6-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy-1.8.0rc1-py2.7.egg-info'
答案 0 :(得分:0)
安装brew
http://brew.sh/
然后按照这个食谱......
https://penandpants.com/2013/04/04/install-scientific-python-on-mac-os-x/
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
export PATH=/usr/local/bin:/usr/local/share/python:$PATH
brew install python
brew tap homebrew/science
brew install gfortran
brew install numpy --with-openblas
brew install scipy --with-openblas
brew install matplotlib
brew install zeromq
pip install ipython
pip install pandas
pip install sklearn
答案 1 :(得分:0)
aptitude purge python-numpy
试试这个
答案 2 :(得分:0)
通过重新安装python https://www.python.org/downloads/
解决了类似的问题