在mac中安装opencv-python时,OSError:[Errno 1]不允许操作

时间:2017-07-18 15:16:41

标签: python python-2.7 opencv numpy

$ pip install opencv-python

收集opencv-python   使用缓存的opencv_python-3.2.0.7-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 收集numpy> = 1.11.1(来自opencv-python)   使用缓存的numpy-1.13.1-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 安装收集的软件包:numpy,opencv-python   找到现有安装:numpy 1.8.0rc1     弃用:已弃用卸载已安装的distutils项目(numpy),将来的版本将删除该项目。这是因为卸载distutils项目只会部分卸载项目。     卸载numpy-1.8.0rc1: 例外: Traceback(最近一次调用最后一次):   文件“/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py”,第215行,主要     status = self.run(options,args)   运行文件“/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py”,第342行     PREFIX = options.prefix_path,   安装文件“/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py”,第778行     requirement.uninstall(auto_confirm =真)   在卸载文件“/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py”,第754行     paths_to_remove.remove(auto_confirm)   文件“/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_uninstall.py”,第115行,删除     重命名(path,new_path)   文件“/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/utils/init.py”,第267行,重命名     shutil.move(旧的,新的)   文件“/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py”,第302行,移动     copy2(src,real_dst)   在copy2中输入文件“/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py”,第131行     copystat(src,dst)   在copystat中输入文件“/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py”,第103行     os.chflags(dst,st.st_flags) OSError:[Errno 1]不允许操作:'/ var /folders/dd/70hgtbs50hl5sr13h93gzzm80000gn/T/pip-BDWfhx-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python /numpy-1.8.0rc1-py2.7.egg-info'

当我尝试使用sudo时,

OSError:[Errno 1]不允许操作:'/ tmp / tip -JhNitO-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy-1.8。 0rc1-py2.7.egg-INFO'

我试图卸载numpy。 但仍然发生权限错误.. OSError:[Errno 1]不允许操作:'/ var / folder / dd / 70hgtbs50hl5sr13h93gzzm80000gn / T / pip -yKfQhH-uninstall / System / Library / Frameworks / Cluster.framework / Version / 7.7 / Extra / lib / python /numpy-1.8.0rc1-py2.7.egg-info'

与sudo, OSError:[Errno 1]不允许操作:'/ tmp / tip-sIVZu9-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy-1.8.0rc1-py2 .7.egg-信息” 目录'/ Users / jack / Library / Caches / pip / http'或其父目录不归当前用户所有,并且已禁用缓存。请检查该目录的权限和所有者。如果用sudo执行pip,你可能需要sudo的-H标志。

最后,我尝试通过pip uninstall python卸载python 但是还有, OSError:[Errno 1]不允许操作:'/ var / folder / dd / 70hgtbs50hl5sr13h93gzzm80000gn / T / pip-7ByYw9-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7 /lib-dynload/Python-2.7.10-py2.7.egg-info'

和sudo, OSError:[Errno 1]不允许操作:'/ tmp / download1UeP4t-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/Python-2.7 .10 py2.7.egg-INFO” 目录'/ Users / jack / Library / Caches / pip / http'或其父目录不归当前用户所有,并且已禁用缓存。请检查该目录的权限和所有者。如果用sudo执行pip,你可能需要sudo的-H标志。

所以..我也递归删除目录。 sudo rm -rf / tmp / pip-1UeP4t-uninstall /

但是那些目录会重现它。

3 个答案:

答案 0 :(得分:0)

使用sudo -H标志和/或使用ignore-installed标志:sudo -H pip install --ignore-installed opencv-python

答案 1 :(得分:0)

sudo -H pip install --ignore-installed opencv-python

这对我有用

答案 2 :(得分:0)

尝试执行此操作namespace App\Http\Controllers; use Illuminate\Http\Request; use DB; use Hash; use App\User; class regController extends Controller { public function create(Request $request) { $this-> validate(request(),[ 'name' => 'required', 'email'=> 'required', 'type' => 'required', 'image' => 'required', 'password' => 'required|confirmed|min:6', ]); $request['password'] = bcrypt($request -> password); $User = new User($request->input()) ; if($file = $request->hasFile('image')) { $file = $request->file('image') ; $fileName = $file->getClientOriginalName() ; return Storages::putFile('public/images',$request->file('image')); $destinationPath = public_path().'images/' ; $file->move($destinationPath,$fileName); $User->image = $fileName ; } $user = User::create(request(['name','email','type','image','password'])); return redirect('login'); } 。这应该有助于将pip install --user opencv-python传递给用户。您不需要setup.py