如何通过pip安装包?

时间:2017-09-04 04:54:07

标签: python pip

我正在尝试安装一个python gui automator,我应该通过pip这样做。在命令提示符下键入pip install pyautogui(以管理员身份)给出了很多例外。这是打印输出:

pip install pyautogui
Traceback (most recent call last):
  File "c:\users\nate4\appdata\local\programs\python\python36-32\lib\site-packages\pip\_vendor\requests\packages\__init__.py", line 27, in <module>
    from . import urllib3
  File "c:\users\nate4\appdata\local\programs\python\python36-32\lib\site-packages\pip\_vendor\requests\packages\urllib3\__init__.py", line 8, in <module>
    from .connectionpool import (
  File "c:\users\nate4\appdata\local\programs\python\python36-32\lib\site-packages\pip\_vendor\requests\packages\urllib3\connectionpool.py", line 7, in <module>
    from socket import error as SocketError, timeout as SocketTimeout
  File "c:\users\nate4\appdata\local\programs\python\python36-32\lib\socket.py", line 49, in <module>
    import _socket
zipimport.ZipImportError: can't find module '_socket'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\nate4\appdata\local\programs\python\python36-32\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\nate4\appdata\local\programs\python\python36-32\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\Nate4\AppData\Local\Programs\Python\Python36-32\Scripts\pip.exe\__main__.py", line 5, in <module>
  File "c:\users\nate4\appdata\local\programs\python\python36-32\lib\site-packages\pip\__init__.py", line 21, in <module>
    from pip._vendor.requests.packages.urllib3.exceptions import DependencyWarning
  File "c:\users\nate4\appdata\local\programs\python\python36-32\lib\site-packages\pip\_vendor\requests\__init__.py", line 62, in <module>
    from .packages.urllib3.exceptions import DependencyWarning
  File "c:\users\nate4\appdata\local\programs\python\python36-32\lib\site-packages\pip\_vendor\requests\packages\__init__.py", line 29, in <module>
    import urllib3
ModuleNotFoundError: No module named 'urllib3'

1 个答案:

答案 0 :(得分:1)

1)转到安装python的目录。 (就我而言,它是C:\ Users ... \ AppData \ Local \ Programs \ Python \ Python36-32)
2)找到名为&#34; Scripts&#34;
的目录 3)按住SHIFT并右键单击该文件夹上的enter image description here。然后单击&#34;在此处打开命令窗口&#34;
4)将弹出一个命令提示符窗口。键入pip install <packagename>,然后按ENTER键。

当我通过pip为python安装软件包时,这个方法对我有用。希望它可以帮到你。