我曾经能够从jupyter笔记本启动pip命令。但是现在即使我勉强使用基本的! pip -V
也可以得到:
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
<ipython-input-17-29b4bf94a9cf> in <module>
----> 1 get_ipython().system(' pip -V')
C:\ProgramData\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py in system_piped(self, cmd)
2450 # a non-None value would trigger :func:`sys.displayhook` calls.
2451 # Instead, we store the exit_code in user_ns.
-> 2452 self.user_ns['_exit_code'] = system(self.var_expand(cmd, depth=1))
2453
2454 def system_raw(self, cmd):
C:\ProgramData\Anaconda3\lib\site-packages\IPython\utils\_process_win32.py in system(cmd)
129 if path is not None:
130 cmd = '"pushd %s &&"%s' % (path, cmd)
--> 131 return process_handler(cmd, _system_body)
132
133 def getoutput(cmd):
C:\ProgramData\Anaconda3\lib\site-packages\IPython\utils\_process_common.py in process_handler(cmd, callback, stderr)
82 stdout=subprocess.PIPE,
83 stderr=stderr,
---> 84 close_fds=close_fds)
85
86 try:
C:\ProgramData\Anaconda3\lib\subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors, text)
773 c2pread, c2pwrite,
774 errread, errwrite,
--> 775 restore_signals, start_new_session)
776 except:
777 # Cleanup if the child failed starting.
C:\ProgramData\Anaconda3\lib\subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, unused_restore_signals, unused_start_new_session)
1176 env,
1177 os.fspath(cwd) if cwd is not None else None,
-> 1178 startupinfo)
1179 finally:
1180 # Child is launched. Close the parent's copy of those pipe
FileNotFoundError: [WinError 2] The system cannot find the file specified
Blockquote
原因可能是我试图从Microsoft Store安装Python,但没有pip,并且我在this tutorial之后下载了pip。
我试图从sys安装它:
import sys
!{sys.executable} -m pip install facebook_sdk]
但是得到了以下一个:
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
<ipython-input-20-378e12e263ed> in <module>
1 import sys
----> 2 get_ipython().system('{sys.executable} -m pip install facebook_sdk')
3
C:\ProgramData\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py in system_piped(self, cmd)
2450 # a non-None value would trigger :func:`sys.displayhook` calls.
2451 # Instead, we store the exit_code in user_ns.
-> 2452 self.user_ns['_exit_code'] = system(self.var_expand(cmd, depth=1))
2453
2454 def system_raw(self, cmd):
C:\ProgramData\Anaconda3\lib\site-packages\IPython\utils\_process_win32.py in system(cmd)
129 if path is not None:
130 cmd = '"pushd %s &&"%s' % (path, cmd)
--> 131 return process_handler(cmd, _system_body)
132
133 def getoutput(cmd):
C:\ProgramData\Anaconda3\lib\site-packages\IPython\utils\_process_common.py in process_handler(cmd, callback, stderr)
82 stdout=subprocess.PIPE,
83 stderr=stderr,
---> 84 close_fds=close_fds)
85
86 try:
C:\ProgramData\Anaconda3\lib\subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors, text)
773 c2pread, c2pwrite,
774 errread, errwrite,
--> 775 restore_signals, start_new_session)
776 except:
777 # Cleanup if the child failed starting.
C:\ProgramData\Anaconda3\lib\subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, unused_restore_signals, unused_start_new_session)
1176 env,
1177 os.fspath(cwd) if cwd is not None else None,
-> 1178 startupinfo)
1179 finally:
1180 # Child is launched. Close the parent's copy of those pipe
FileNotFoundError: [WinError 2] The system cannot find the file specified
我尝试使用conda install pip
安装它(和一个随机软件包),但是得到了几乎相同的错误
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
<ipython-input-6-6460b4216065> in <module>
----> 1 get_ipython().run_line_magic('conda', 'install pip')
C:\ProgramData\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py in run_line_magic(self, magic_name, line, _stack_depth)
2311 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
2312 with self.builtin_trap:
-> 2313 result = fn(*args, **kwargs)
2314 return result
2315
<C:\ProgramData\Anaconda3\lib\site-packages\decorator.py:decorator-gen-108> in conda(self, line)
C:\ProgramData\Anaconda3\lib\site-packages\IPython\core\magic.py in <lambda>(f, *a, **k)
185 # but it's overkill for just that one bit of state.
186 def magic_deco(arg):
--> 187 call = lambda f, *a, **k: f(*a, **k)
188
189 if callable(arg):
C:\ProgramData\Anaconda3\lib\site-packages\IPython\core\magics\packaging.py in conda(self, line)
101 extra_args.extend(["--prefix", sys.prefix])
102
--> 103 self.shell.system(' '.join([conda, command] + extra_args + args))
104 print("\nNote: you may need to restart the kernel to use updated packages.")
C:\ProgramData\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py in system_piped(self, cmd)
2450 # a non-None value would trigger :func:`sys.displayhook` calls.
2451 # Instead, we store the exit_code in user_ns.
-> 2452 self.user_ns['_exit_code'] = system(self.var_expand(cmd, depth=1))
2453
2454 def system_raw(self, cmd):
C:\ProgramData\Anaconda3\lib\site-packages\IPython\utils\_process_win32.py in system(cmd)
129 if path is not None:
130 cmd = '"pushd %s &&"%s' % (path, cmd)
--> 131 return process_handler(cmd, _system_body)
132
133 def getoutput(cmd):
C:\ProgramData\Anaconda3\lib\site-packages\IPython\utils\_process_common.py in process_handler(cmd, callback, stderr)
82 stdout=subprocess.PIPE,
83 stderr=stderr,
---> 84 close_fds=close_fds)
85
86 try:
C:\ProgramData\Anaconda3\lib\subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors, text)
773 c2pread, c2pwrite,
774 errread, errwrite,
--> 775 restore_signals, start_new_session)
776 except:
777 # Cleanup if the child failed starting.
C:\ProgramData\Anaconda3\lib\subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, unused_restore_signals, unused_start_new_session)
1176 env,
1177 os.fspath(cwd) if cwd is not None else None,
-> 1178 startupinfo)
1179 finally:
1180 # Child is launched. Close the parent's copy of those pipe
FileNotFoundError: [WinError 2] The system cannot find the file specified
(base) C:\Users\antoi>python -m pip install --upgrade pip
Collecting pip
Using cached https://files.pythonhosted.org/packages/30/db/9e38760b32e3e7f40cce46dd5fb107b8c73840df38f0046d8e6514e675a1/pip-19.2.3-py2.py3-none-any.whl
Installing collected packages: pip
Found existing installation: pip 19.1.1
Uninstalling pip-19.1.1:
ERROR: Could not install packages due to an EnvironmentError: [WinError 5] Access is denied: 'c:\\programdata\\anaconda3\\lib\\site-packages\\pip\\_internal\\build_env.py'
Consider using the `--user` option or check the permissions.
(base) C:\Users\antoi>
(base) C:\Users\antoi>python -m pip install --upgrade pip --user
Collecting pip
Using cached https://files.pythonhosted.org/packages/30/db/9e38760b32e3e7f40cce46dd5fb107b8c73840df38f0046d8e6514e675a1/pip-19.2.3-py2.py3-none-any.whl
Installing collected packages: pip
Successfully installed pip-19.2.3
但是在关闭内核,关闭jupyter窗口终端之后仍然出现错误。
答案 0 :(得分:0)
所以您正在使用conda和Pip ...为什么不尝试从Conda安装pip?
很抱歉没有发表评论,但是我的信誉不够。
conda install pip