5 python powershell virtualenv python-venv
我创建了名为bitcoin_notifications.py的 virtualenv ,我将激活它,但是:
PS C:\Users\piotr> bitcoin_notifications\activate.ps1
Run Code Online (Sandbox Code Playgroud)
PS C:\Users\piotr> bitcoin_notifications\activate.ps1
Run Code Online (Sandbox Code Playgroud)
在我们阅读之前共享的结果中,无法加载模块,如果需要更多信息,请运行另一个特定命令。
一旦我运行它,
bitcoin_notifications\activate.ps1 : ```The module
'bitcoin_notifications' could not be loaded. For more information, run
'Import-Module bitcoin_notifications'.``` At line:1 char:1
+ bitcoin_notifications\activate.ps1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (bitcoin_notifications\activate.ps1:String) [],
CommandNotFoundException
+ FullyQualifiedErrorId : CouldNotAutoLoadModule
Run Code Online (Sandbox Code Playgroud)
我们可以理解该目录中没有模块。我只是想激活 virtualenv。我怎样才能做到这一点?
编辑:我正在复制创建新 venv 的方法:
pip install virtualenvmkdir Environmentscd !$virtualenv bitcoin_notificationsbitcoin_notifications\activate.ps1activate.ps1的第一行似乎提到了解决方案:
\n# This file must be dot sourced from PoSh; you cannot run it\n# directly. Do this: . ./activate.ps1\nRun Code Online (Sandbox Code Playgroud)\n因此,以下内容应该有效(方法 \xe2\x80\x94 中的步骤 4 和 5 请注意,步骤 5 缺少点!):
\nvirtualenv bitcoin_notifications\n. .\\bitcoin_notifications\\Scripts\\activate.ps1\nRun Code Online (Sandbox Code Playgroud)\n注意:您的问题提到venv但实际上是关于virtualenv. 请注意,这是两个相似但不同的工具。另外,在第 5 步中您错过了“脚本”部分。也许这是编写问题时的复制粘贴错误,但请确保包含它。