Пип больше не работает в ноутбуке Jupyter - PullRequest
0 голосов
/ 14 октября 2019

Раньше я мог запускать команду pip из блокнота jupyter. Но теперь, даже если я возьму с собой даже базовые ! 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

Возможно, причина в том, что я попытался установить Python из Microsoft Store, в котором не было pip, и что я скачал 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 в ноутбуке jupyter

Я пытался установить его (и случайный пакет) с 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

обновить пункт в приглашении Anaconda

(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.

1 Ответ

0 голосов
/ 14 октября 2019

Итак, вы используете conda и Pip ... почему бы вам не попробовать установить pip из Conda ??

Извините, что не комментирую, но у меня недостаточно репутации.

conda install pip
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...