打開cmd窗口,輸入 virtualenv -h 確認現有環境是否有 virtualenv,有則顯示如下,沒有則安裝 virtualenv
C:\Users\wangshengke>virtualenv -h
Usage: virtualenv [OPTIONS] DEST_DIR
Options:
--version show program's version number and exit
-h, --help show this help message and exit
-v, --verbose Increase verbosity.
。。。。。。
D:\pyvenv_a>pip install virtualenv
Collecting virtualenv
Downloading https://files.pythonhosted.org/packages/33/5d/314c760d4204f64e4a968275182b7751bd5c3249094757b39ba987dcfb5a/virtualenv-16.4.3-py2.py3-none-any.whl (2.0MB)
D:\pyvenv_a> virtualenv --no-site-packages venv
Using base prefix 'F:\\Program_File\\anaconda3'
New python executable in D:\pyvenv_a\venv\Scripts\python.exe
copying F:\Program_File\anaconda3\python.exe => D:\pyvenv_a\venv\Scripts\python.exe
Installing setuptools, pip, wheel...done.
D:\pyvenv_a>
D:\pyvenv_a>cd venv\Scripts\
D:\pyvenv_a\venv\Scripts>activate
(venv) D:\pyvenv_a\venv\Scripts>
(venv) D:\pyvenv_a>pip install pyinstaller
Collecting pyinstaller
Downloading https://files.pythonhosted.org/packages/03/32/0e0de593f129bf1d1e77eed562496d154ef4460fd5cecfd78612ef39a0cc/PyInstaller-3.4.tar.gz (3.5MB)
Exception:
v = self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out
解決方案:
根據地址上述地址 手動下載 https://files.pythonhosted.org/packages/03/32/0e0de593f129bf1d1e77eed562496d154ef4460fd5cecfd78612ef39a0cc/PyInstaller-3.4.tar.gz
然後放到當前目錄,調用pip install PyInstaller-3.4.tar.gz 安裝
(venv) D:\pyvenv_a\venv>pip istall PyInstaller-3.4.tar.gz
(venv) D:\pyvenv_a\venv>where pyinstaller
F:\Program_File\anaconda3\Scripts\pyinstaller.exe
(venv) D:\pyvenv_a\venv>
(venv) D:\pyvenv_a\venv>where pyinstaller
D:\pyvenv_a\venv\Scripts\pyinstaller.exe
F:\Program_File\anaconda3\Scripts\pyinstaller.exe
(venv) D:\pyvenv_a\venv>