Virtualenv: Tidak dapat menonaktifkan virtualenv saat menggunakan Powershell di Terminal Windows

Dibuat pada 27 Mar 2020  ·  6Komentar  ·  Sumber: pypa/virtualenv

Isu

Tidak dapat menonaktifkan lingkungan virtual saat menggunakan Powershell di Terminal Windows.

Lingkungan Hidup
Windows 10 Pro 10.0.18363
Terminal Windows (Powershell)

console pip 20.0.2 setuptools 46.0.0 wheel 0.34.2

Output dari pembuatan lingkungan virtual

PS D:\projects\ceres> virtualenv . -vvv --with-traceback
56 setup logging to NOTSET [DEBUG report:43]
57 could not create app data folder C:\Users\Spors\AppData\Local\pypa\virtualenv due to FileNotFoundError(2, 'The syste
m cannot find the path specified') [INFO app_data:54]
70 created temporary app data folder C:\Users\Spors\AppData\Local\Temp\tmpbehz5s21 [DEBUG app_data:32]
70 find interpreter for spec PythonSpec(path=c:\program files\python\38\python.exe) [INFO builtin:44]
70 proposed PythonInfo(spec=CPython3.8.1.final.0-64, exe=c:\program files\python\38\python.exe, platform=win32, version
='3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)]', encoding_fs_io=utf-8-utf-8) [INFO bu
iltin:50]
71 accepted PythonInfo(spec=CPython3.8.1.final.0-64, exe=c:\program files\python\38\python.exe, platform=win32, version
='3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)]', encoding_fs_io=utf-8-utf-8) [DEBUG b
uiltin:52]
76 symlink on filesystem does not work [DEBUG info:47]
76 filesystem is not case-sensitive [DEBUG info:28]
142 create virtual environment via CPython3Windows(dest=D:\projects\ceres, clear=False, global=False) [INFO session:52]
143 create folder D:\projects\ceres\Lib\site-packages [DEBUG _sync:21]
143 create folder D:\projects\ceres\Scripts [DEBUG _sync:21]
143 write D:\projects\ceres\pyvenv.cfg [DEBUG pyenv_cfg:34]
143     home = c:\program files\python\38 [DEBUG pyenv_cfg:38]
143     implementation = CPython [DEBUG pyenv_cfg:38]
143     version_info = 3.8.1.final.0 [DEBUG pyenv_cfg:38]
143     virtualenv = 20.0.10 [DEBUG pyenv_cfg:38]
144     include-system-site-packages = false [DEBUG pyenv_cfg:38]
144     base-prefix = c:\program files\python\38 [DEBUG pyenv_cfg:38]
144     base-exec-prefix = c:\program files\python\38 [DEBUG pyenv_cfg:38]
144     base-executable = c:\program files\python\38\python.exe [DEBUG pyenv_cfg:38]
144 copy c:\program files\python\38\python.exe to D:\projects\ceres\Scripts\python.exe [DEBUG _sync:48]
146 copy c:\program files\python\38\pythonw.exe to D:\projects\ceres\Scripts\pythonw.exe [DEBUG _sync:48]
147 copy c:\program files\python\38\python3.dll to D:\projects\ceres\Scripts\python3.dll [DEBUG _sync:48]
148 copy c:\program files\python\38\python38.dll to D:\projects\ceres\Scripts\python38.dll [DEBUG _sync:48]
158 copy c:\program files\python\38\vcruntime140.dll to D:\projects\ceres\Scripts\vcruntime140.dll [DEBUG _sync:48]
159 copy c:\program files\python\38\DLLs\libcrypto-1_1.dll to D:\projects\ceres\Scripts\libcrypto-1_1.dll [DEBUG _sync:
48]
167 copy c:\program files\python\38\DLLs\libffi-7.dll to D:\projects\ceres\Scripts\libffi-7.dll [DEBUG _sync:48]
168 copy c:\program files\python\38\DLLs\libssl-1_1.dll to D:\projects\ceres\Scripts\libssl-1_1.dll [DEBUG _sync:48]
171 copy c:\program files\python\38\DLLs\pyexpat.pyd to D:\projects\ceres\Scripts\pyexpat.pyd [DEBUG _sync:48]
172 copy c:\program files\python\38\DLLs\select.pyd to D:\projects\ceres\Scripts\select.pyd [DEBUG _sync:48]
173 copy c:\program files\python\38\DLLs\sqlite3.dll to D:\projects\ceres\Scripts\sqlite3.dll [DEBUG _sync:48]
177 copy c:\program files\python\38\DLLs\tcl86t.dll to D:\projects\ceres\Scripts\tcl86t.dll [DEBUG _sync:48]
179 copy c:\program files\python\38\DLLs\tk86t.dll to D:\projects\ceres\Scripts\tk86t.dll [DEBUG _sync:48]
181 copy c:\program files\python\38\DLLs\unicodedata.pyd to D:\projects\ceres\Scripts\unicodedata.pyd [DEBUG _sync:48]
185 copy c:\program files\python\38\DLLs\winsound.pyd to D:\projects\ceres\Scripts\winsound.pyd [DEBUG _sync:48]
186 copy c:\program files\python\38\DLLs\_asyncio.pyd to D:\projects\ceres\Scripts\_asyncio.pyd [DEBUG _sync:48]
187 copy c:\program files\python\38\DLLs\_bz2.pyd to D:\projects\ceres\Scripts\_bz2.pyd [DEBUG _sync:48]
188 copy c:\program files\python\38\DLLs\_ctypes.pyd to D:\projects\ceres\Scripts\_ctypes.pyd [DEBUG _sync:48]
189 copy c:\program files\python\38\DLLs\_decimal.pyd to D:\projects\ceres\Scripts\_decimal.pyd [DEBUG _sync:48]
190 copy c:\program files\python\38\DLLs\_elementtree.pyd to D:\projects\ceres\Scripts\_elementtree.pyd [DEBUG _sync:48
]
192 copy c:\program files\python\38\DLLs\_hashlib.pyd to D:\projects\ceres\Scripts\_hashlib.pyd [DEBUG _sync:48]
193 copy c:\program files\python\38\DLLs\_lzma.pyd to D:\projects\ceres\Scripts\_lzma.pyd [DEBUG _sync:48]
194 copy c:\program files\python\38\DLLs\_msi.pyd to D:\projects\ceres\Scripts\_msi.pyd [DEBUG _sync:48]
195 copy c:\program files\python\38\DLLs\_multiprocessing.pyd to D:\projects\ceres\Scripts\_multiprocessing.pyd [DEBUG
_sync:48]
196 copy c:\program files\python\38\DLLs\_overlapped.pyd to D:\projects\ceres\Scripts\_overlapped.pyd [DEBUG _sync:48]
197 copy c:\program files\python\38\DLLs\_queue.pyd to D:\projects\ceres\Scripts\_queue.pyd [DEBUG _sync:48]
198 copy c:\program files\python\38\DLLs\_socket.pyd to D:\projects\ceres\Scripts\_socket.pyd [DEBUG _sync:48]
199 copy c:\program files\python\38\DLLs\_sqlite3.pyd to D:\projects\ceres\Scripts\_sqlite3.pyd [DEBUG _sync:48]
200 copy c:\program files\python\38\DLLs\_ssl.pyd to D:\projects\ceres\Scripts\_ssl.pyd [DEBUG _sync:48]
200 copy c:\program files\python\38\DLLs\_tkinter.pyd to D:\projects\ceres\Scripts\_tkinter.pyd [DEBUG _sync:48]
201 create D:\projects\ceres\Lib\site-packages\_virtualenv.py [DEBUG api:60]
203 create virtualenv import hook file D:\projects\ceres\Lib\site-packages\_virtualenv.pth [DEBUG api:63]
203 ============================== target debug ============================== [DEBUG session:54]
203 debug via 'D:\projects\ceres\Scripts\python.exe' 'c:\program files\python\38\lib\site-packages\virtualenv\create\de
bug.py' [DEBUG creator:182]
203 {
  "sys": {
    "executable": "D:\\projects\\ceres\\Scripts\\python.exe",
    "_base_executable": "D:\\projects\\ceres\\Scripts\\python.exe",
    "prefix": "D:\\projects\\ceres",
    "base_prefix": "c:\\program files\\python\\38",
    "real_prefix": null,
    "exec_prefix": "D:\\projects\\ceres",
    "base_exec_prefix": "c:\\program files\\python\\38",
    "path": [
      "D:\\projects\\ceres\\Scripts\\python38.zip",
      "c:\\program files\\python\\38\\DLLs",
      "c:\\program files\\python\\38\\lib",
      "c:\\program files\\python\\38",
      "D:\\projects\\ceres",
      "D:\\projects\\ceres\\lib\\site-packages"
    ],
    "meta_path": [
      "<class '_virtualenv._Finder'>",
      "<class '_frozen_importlib.BuiltinImporter'>",
      "<class '_frozen_importlib.FrozenImporter'>",
      "<class '_frozen_importlib_external.PathFinder'>"
    ],
    "fs_encoding": "utf-8",
    "io_encoding": "cp1252"
  },
  "version": "3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)]",
  "os": "<module 'os' from 'c:\\\\program files\\\\python\\\\38\\\\lib\\\\os.py'>",
  "site": "<module 'site' from 'c:\\\\program files\\\\python\\\\38\\\\lib\\\\site.py'>",
  "datetime": "<module 'datetime' from 'c:\\\\program files\\\\python\\\\38\\\\lib\\\\datetime.py'>",
  "math": "<module 'math' (built-in)>",
  "json": "<module 'json' from 'c:\\\\program files\\\\python\\\\38\\\\lib\\\\json\\\\__init__.py'>"
} [DEBUG session:55]
295 add seed packages via FromAppData(download=False, pip=latest, setuptools=latest, wheel=latest, via=copy, app_data_d
ir=C:\Users\Spors\AppData\Local\Temp\tmpbehz5s21\seed-app-data\v1) [INFO session:59]
296 Attempting to acquire lock 2491013030048 on C:\Users\Spors\AppData\Local\Temp\tmpbehz5s21\seed-app-data\v1\3.8\whee
ls.lock [DEBUG filelock:270]
296 Lock 2491013030048 acquired on C:\Users\Spors\AppData\Local\Temp\tmpbehz5s21\seed-app-data\v1\3.8\wheels.lock [INFO
 filelock:274]
297 get bundled wheel c:\program files\python\38\lib\site-packages\virtualenv\seed\embed\wheels\pip-20.0.2-py2.py3-none
-any.whl [DEBUG acquire:51]
297 get bundled wheel c:\program files\python\38\lib\site-packages\virtualenv\seed\embed\wheels\setuptools-46.0.0-py3-n
one-any.whl [DEBUG acquire:51]
297 get bundled wheel c:\program files\python\38\lib\site-packages\virtualenv\seed\embed\wheels\wheel-0.34.2-py2.py3-no
ne-any.whl [DEBUG acquire:51]
300 install wheel from wheel C:\Users\Spors\AppData\Local\Temp\tmpbehz5s21\seed-app-data\v1\3.8\wheels\wheel-0.34.2-py2
.py3-none-any.whl via CopyPipInstall [DEBUG via_app_data:46]
300 install setuptools from wheel C:\Users\Spors\AppData\Local\Temp\tmpbehz5s21\seed-app-data\v1\3.8\wheels\setuptools-
46.0.0-py3-none-any.whl via CopyPipInstall [DEBUG via_app_data:46]
300 build install image to C:\Users\Spors\AppData\Local\Temp\tmpbehz5s21\seed-app-data\v1\3.8\image\CopyPipInstall\whee
l-0.34.2-py2.py3-none-any of wheel-0.34.2-py2.py3-none-any.whl [DEBUG base:57]
300 install pip from wheel C:\Users\Spors\AppData\Local\Temp\tmpbehz5s21\seed-app-data\v1\3.8\wheels\pip-20.0.2-py2.py3
-none-any.whl via CopyPipInstall [DEBUG via_app_data:46]
301 build install image to C:\Users\Spors\AppData\Local\Temp\tmpbehz5s21\seed-app-data\v1\3.8\image\CopyPipInstall\setu
ptools-46.0.0-py3-none-any of setuptools-46.0.0-py3-none-any.whl [DEBUG base:57]
301 build install image to C:\Users\Spors\AppData\Local\Temp\tmpbehz5s21\seed-app-data\v1\3.8\image\CopyPipInstall\pip-
20.0.2-py2.py3-none-any of pip-20.0.2-py2.py3-none-any.whl [DEBUG base:57]
334 copy directory C:\Users\Spors\AppData\Local\Temp\tmpbehz5s21\seed-app-data\v1\3.8\image\CopyPipInstall\wheel-0.34.2
-py2.py3-none-any\wheel to D:\projects\ceres\Lib\site-packages\wheel [DEBUG _sync:48]
397 copy C:\Users\Spors\AppData\Local\Temp\tmpbehz5s21\seed-app-data\v1\3.8\image\CopyPipInstall\setuptools-46.0.0-py3-
none-any\easy_install.py to D:\projects\ceres\Lib\site-packages\easy_install.py [DEBUG _sync:48]
402 copy directory C:\Users\Spors\AppData\Local\Temp\tmpbehz5s21\seed-app-data\v1\3.8\image\CopyPipInstall\setuptools-4
6.0.0-py3-none-any\pkg_resources to D:\projects\ceres\Lib\site-packages\pkg_resources [DEBUG _sync:48]
408 copy directory C:\Users\Spors\AppData\Local\Temp\tmpbehz5s21\seed-app-data\v1\3.8\image\CopyPipInstall\wheel-0.34.2
-py2.py3-none-any\wheel-0.34.2.dist-info to D:\projects\ceres\Lib\site-packages\wheel-0.34.2.dist-info [DEBUG _sync:48]
429 copy C:\Users\Spors\AppData\Local\Temp\tmpbehz5s21\seed-app-data\v1\3.8\image\CopyPipInstall\wheel-0.34.2-py2.py3-n
one-any\wheel-0.34.2.virtualenv to D:\projects\ceres\Lib\site-packages\wheel-0.34.2.virtualenv [DEBUG _sync:48]
432 generated console scripts wheel.exe wheel3.exe wheel-3.8.exe [DEBUG base:53]
479 copy directory C:\Users\Spors\AppData\Local\Temp\tmpbehz5s21\seed-app-data\v1\3.8\image\CopyPipInstall\setuptools-4
6.0.0-py3-none-any\setuptools to D:\projects\ceres\Lib\site-packages\setuptools [DEBUG _sync:48]
554 copy directory C:\Users\Spors\AppData\Local\Temp\tmpbehz5s21\seed-app-data\v1\3.8\image\CopyPipInstall\pip-20.0.2-p
y2.py3-none-any\pip to D:\projects\ceres\Lib\site-packages\pip [DEBUG _sync:48]
857 copy directory C:\Users\Spors\AppData\Local\Temp\tmpbehz5s21\seed-app-data\v1\3.8\image\CopyPipInstall\setuptools-4
6.0.0-py3-none-any\setuptools-46.0.0.dist-info to D:\projects\ceres\Lib\site-packages\setuptools-46.0.0.dist-info [DEBU
G _sync:48]
884 copy C:\Users\Spors\AppData\Local\Temp\tmpbehz5s21\seed-app-data\v1\3.8\image\CopyPipInstall\setuptools-46.0.0-py3-
none-any\setuptools-46.0.0.virtualenv to D:\projects\ceres\Lib\site-packages\setuptools-46.0.0.virtualenv [DEBUG _sync:
1764 copy C:\Users\Spors\AppData\Local\Temp\tmpbehz5s21\seed-app-data\v1\3.8\image\CopyPipInstall\pip-20.0.2-py2.py3-none-any\pip-20.0.2.virtualenv to D:\projects\ceres\Lib\site-packages\pip-20.0.2.virtualenv [DEBUG _sync:48]
1767 generated console scripts pip.exe pip3.exe pip-3.8.exe [DEBUG base:53]
1767 Attempting to release lock 2491013030048 on C:\Users\Spors\AppData\Local\Temp\tmpbehz5s21\seed-app-data\v1\3.8\wheels.lock [DEBUG filelock:315]
1767 Lock 2491013030048 released on C:\Users\Spors\AppData\Local\Temp\tmpbehz5s21\seed-app-data\v1\3.8\wheels.lock [INFO filelock:318]
1768 add activators for Bash, Batch, Fish, PowerShell, Python, Xonsh [INFO session:64]
1771 write D:\projects\ceres\pyvenv.cfg [DEBUG pyenv_cfg:34]
1771    home = c:\program files\python\38 [DEBUG pyenv_cfg:38]
1771    implementation = CPython [DEBUG pyenv_cfg:38]
1771    version_info = 3.8.1.final.0 [DEBUG pyenv_cfg:38]
1771    virtualenv = 20.0.10 [DEBUG pyenv_cfg:38]
1771    include-system-site-packages = false [DEBUG pyenv_cfg:38]
1771    base-prefix = c:\program files\python\38 [DEBUG pyenv_cfg:38]
1771    base-exec-prefix = c:\program files\python\38 [DEBUG pyenv_cfg:38]
1771    base-executable = c:\program files\python\38\python.exe [DEBUG pyenv_cfg:38]
1772 remove temporary app data folder C:\Users\Spors\AppData\Local\Temp\tmpbehz5s21 [DEBUG app_data:35]
1825 created virtual environment CPython3.8.1.final.0-64 in 1773ms
  creator CPython3Windows(dest=D:\projects\ceres, clear=False, global=False)
  seeder FromAppData(download=False, pip=latest, setuptools=latest, wheel=latest, via=copy, app_data_dir=C:\Users\Spors\AppData\Local\Temp\tmpbehz5s21\seed-app-data\v1)
  activators BashActivator,BatchActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator [WARNING __main__:21]

Solusi sampai diperbaiki
Lihat https://github.com/pypa/virtualenv/issues/1724#issuecomment-604964446

bug help-wanted needs-reproducer

Komentar yang paling membantu

Ini yang saya coba jelaskan di utas lain juga, sepertinya saya gagal. Kami menyediakan skrip aktivasi. Untuk penonaktifan, harapannya bukanlah bahwa Anda akan memiliki skrip penonaktifan melainkan mengetik penonaktifan di Shell akan melakukan penonaktifan. Satu-satunya alasan aktivasi Batch memiliki penonaktifan adalah karena tidak memungkinkan untuk menentukan skrip penonaktifan selama aktivasi, jadi kami mengatasi masalah itu dengan memiliki skrip penonaktifan yang kami masukkan ke jalur.

Semua 6 komentar

Apakah Anda mencoba jika masalah berlanjut dengan terminal lain?

Laporan menunjukkan pembuatan lingkungan virtual, tetapi tidak menunjukkan cara mereproduksi masalah. Saya telah mengkonfirmasi di PC saya bahwa saya dapat membuat, mengaktifkan dan menonaktifkan virtualenv di Terminal Windows:

>virtualenv xxx
created virtual environment CPython3.8.1.final.0-64 in 2468ms
  creator CPython3Windows(dest=C:\Work\Projects\pip\xxx, clear=False, global=False)
  seeder FromAppData(download=False, pip=latest, setuptools=latest, wheel=latest, via=copy, app_data_dir=C:\Users\Gustav\AppData\Local\pypa\virtualenv\seed-app-data\v1
.0.1)
  activators BashActivator,BatchActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
>.\xxx\Scripts\activate.ps1
(xxx) >deactivate
>

Jika Anda dapat memberikan instruksi tentang cara mereproduksi masalah, saya akan mencobanya dan mengonfirmasi apakah saya bisa mendapatkan masalah yang sama.

Apakah Anda mencoba jika masalah berlanjut dengan terminal lain?

Itu terjadi hanya dengan cmd Powershell.

Laporan menunjukkan pembuatan lingkungan virtual, tetapi tidak menunjukkan cara mereproduksi masalah. Saya telah mengkonfirmasi di PC saya bahwa saya dapat membuat, mengaktifkan dan menonaktifkan virtualenv di Terminal Windows:

>virtualenv xxx
created virtual environment CPython3.8.1.final.0-64 in 2468ms
  creator CPython3Windows(dest=C:\Work\Projects\pip\xxx, clear=False, global=False)
  seeder FromAppData(download=False, pip=latest, setuptools=latest, wheel=latest, via=copy, app_data_dir=C:\Users\Gustav\AppData\Local\pypa\virtualenv\seed-app-data\v1
.0.1)
  activators BashActivator,BatchActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
>.\xxx\Scripts\activate.ps1
(xxx) >deactivate
>

Jika Anda dapat memberikan instruksi tentang cara mereproduksi masalah, saya akan mencobanya dan mengonfirmasi apakah saya bisa mendapatkan masalah yang sama.

Apa versi PowerShell Anda saat ini? Lari saja.

Get-Host | Select-Object Version

Saya tidak dapat memberikan instruksi apa pun karena saya tidak melakukan sesuatu yang berbeda dari Anda.

virtualenv . -vvv --with-traceback
./Scripts/activate
./Scripts/deactivate

@Halfbax harapannya adalah ini akan berhasil:

virtualenv . -vvv --with-traceback
./Scripts/activate
deactivate

Catatan, tidak memanggil skrip yang dinonaktifkan secara langsung. Bisakah Anda menunjukkan hasil dari ketiganya?

@gaborbernat

Memanggilnya secara langsung tampaknya menjadi masalah. Saya dapat mereproduksinya dengan Powershell 5/6/7.

Ini bekerja.

deactivate

Skrip aktivasi atau deaktivasi menghasilkan output apa pun. Anda dapat menutup utas ini. Jika tidak apa-apa bagi Anda bahwa skrip penonaktifan tidak berfungsi saat dipanggil langsung.

Ini yang saya coba jelaskan di utas lain juga, sepertinya saya gagal. Kami menyediakan skrip aktivasi. Untuk penonaktifan, harapannya bukanlah bahwa Anda akan memiliki skrip penonaktifan melainkan mengetik penonaktifan di Shell akan melakukan penonaktifan. Satu-satunya alasan aktivasi Batch memiliki penonaktifan adalah karena tidak memungkinkan untuk menentukan skrip penonaktifan selama aktivasi, jadi kami mengatasi masalah itu dengan memiliki skrip penonaktifan yang kami masukkan ke jalur.

Apakah halaman ini membantu?
0 / 5 - 0 peringkat