问题描述:

最近,进入VS Code,进入“Python: 选择Python解释器”后,创建或选择.venv虚拟环境,打开终端,运行pip --version,发现此时pip位置处于全局环境下。手动激活虚拟环境,再运行pip --version,此时pip位置正确。

应该是怎样的?

打开终端时,应该自动进入虚拟环境。

解决办法:

  1. 下载Python Environments(ms-python.vscode-python-envs)扩展。
  2. 在settings.json中添加"python.useEnvironmentsExtension": true

参考:

Terminal no longer auto-activating #25291

You may now see that when you open a new terminal, it does not auto-activate the python environment in this terminal.

This issue includes information and resolution to this problem:

We have decided to turn off the experiment “pythonTerminalEnvVarActivation” on VS Code Insiders. (It is still enabled for users on VS Code stable in the interim) This experiment was created a while back to implement auto-terminal activation, but proved to be buggy and highlighted that this approach is difficult to get right for every user. We are now moving over fully to the Python Environments extension as our long-term solution to all environment related tasks. This new extension will work hand in hand with the Python extension to provide a very much improved experience. Learn more about our roll out of this extension by default to Python users here.

With this in mind, these are the steps to get back environment auto-activation upon opening a terminal:

  1. Install the Python Environments Extension (published by Microsoft): https://marketplace.visualstudio.com/items?itemName=ms-python.vscode-python-envs
  2. Add "python.useEnvironmentsExtension": true, to your USER settings (there is a chance this setting will show as “unknown” but it works)
  3. Final do either:
    A. Do nothing which keeps "python-envs.terminal.autoActivationType" to its default value command and the activation command will be run in each terminal on open
    B. Add "python-envs.terminal.autoActivationType": "shellStartup" to your settings (user or workspace) which will inject the activation script into your shell script for a more automatic activation. Shell startup is only supported for zsh, fsh, pwsh, bash, and cmd.
    Thank you everyone for your patience and feedback!

“请、、请您稍等!!就、、就快好了!”鱼干抱住,并企图藏住这个页面,说道。

(才不是没写完就发出来了

此页面正在 施工中……

您可能会看见 如下内容 出现在此页面中:

  • 一只忘记带安全帽的鱼干(只是是找不到了而已
  • 一些物被干随意堆放( 简称杂鱼 ~
  • 一个“此页面正在 施工中…… 的标志牌⚠”(虽然鱼干不觉得有谁会看见,但万一呢……

这是我最近花了一天和一个晚上摸的项目。主要是为了复习(才不是因为忘记了)一下相关接口的用法。

源码:github

ai公司

当我们需要解决复杂问题的时候,可能会发现ai的脑子不够用。

ai简单运行结构

于是,我们可以将多个ai组织成一个公司,让他们协作完成任务。

以下是我们的ai公司的组织架构图:

ai公司组织结构图

等等,好像太复杂了!

让我们进行一些优化:

ai公司组织架构图-初始

现在看起来好多了。

那些优化掉的人总是需要的(毕竟我们砍掉了所有动脉)。

不过作为一个开始,还是不错的。

让ai把自己组织起来

HR负责公司的招聘事务。

说是招聘,其实是写promts。

例子:

  • USER -> MANAGER: 帮我用python写一个hello world。
  • MANAGER -> HR: 我司需要一名python开发专家!
  • HR -> SYSTEM: “python 工程师”, 0.0, “【一些提示词……】”
  • HR -> MANAGER: 我招聘了一名python工程师。
  • MANAGER -> PYTHON_ENGINEER: 帮我用python写一个hello world。
  • PYTHON_ENGINEER -> MANAGER: 【代码】
  • MANAGER -> USER: 这是用python写的hello world:【代码】

这样可以让ai专人干专事。

二分答案

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/// @brief 二分答案(闭区间)
/// @tparam T 数字类型
/// @param l 左初始值
/// @param r 右初始值
/// @param check 检查答案在左还是右的函数,若true则向右移动,否则向左移动
/// @param reverseAns 是否反转答案
/// @return 答案
template <typename T = int>
T ba(T l, T r, bool (*check)(T), bool reverseAns = false)
{
T m = 0, ans = 0;
while (r >= l)
{
m = (l + r) >> 1;

// cout<<"l: "<<l<<" r: "<<r<<" m: "<<m<<endl;

if (check(m))
{
ans = reverseAns ? ans : m;
l = m + 1;
}
else
{
ans = reverseAns ? m : ans;
r = m - 1;
}
}

return ans;
}

/// @brief 二分答案(左开右闭,向左寻找)
/// @tparam T 数字类型
/// @param l 左初始值
/// @param r 右初始值
/// @param check 检查答案在左还是右的函数,若true则向右移动,否则向左移动
/// @return 答案
template <typename T = int>
T baL(T l, T r, bool (*check)(T))
{
while (l < r)
{
T m = (l + r) >> 1;

// cout<<"l: "<<l<<" r: "<<r<<" m: "<<m<<endl;

if (check(m))
l = m + 1;
else
r = m;
}

return r;
}

/// @brief 二分答案(左闭右开,向右寻找)
/// @tparam T 数字类型
/// @param l 左初始值
/// @param r 右初始值
/// @param check 检查答案在左还是右的函数,若true则向右移动,否则向左移动
/// @return 答案
template <typename T = int>
T baR(T l, T r, bool (*check)(T))
{
while (l < r)
{
T m = (l + r + 1) >> 1;

// cout<<"l: "<<l<<" r: "<<r<<" m: "<<m<<endl;

if (check(m))
l = m;
else
r = m - 1;
}

return r;
}

一段简单的代码,为hexo增加了一个tag-plugin,实现一些可以复用的模板。

代码

template.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
'use strict';

var fs = require("hexo-fs");
var pathFn = require("path");

var template = function (args) {
let filename = args.join(" ");
let path = pathFn.join(hexo.source_dir, "templates", `${filename}.md`);

return fs.readFile(path).then(content =>
hexo.post.render(path, { content: content, _content: content }).then(value =>
`<div class="hexo-template ${filename}">${value.content}</div>`
)
);
}

hexo.extend.tag.register('template', template, { async: true },);
hexo.extend.tag.register('tpl', template, { async: true },);

食用方法

  1. 在./scripts文件夹中创建template.js文档并复制以上内容
  2. 在./source文件夹中创建templates文件夹
  3. 在新建的文件夹中创建需要的模板,文件需为markdown文件,如foo.md
  4. 使用{% template <filename> %}{% tpl <filename> %}插入模板,如{% tpl foo %}

实例

source/templates/constructing.md
1
2
3
4
5
6
7
8
9
10
11
12
{% note warning %}

**“请、、请您稍等!!就、、就快好了!”鱼干抱住,并企图藏住这个页面,说道。**

此页面正在 **施工中……**

您可能会看见 **如下内容** 出现在此页面中:
- 一只忘记带安全帽的鱼干(只是是找不到了而已
- 一些**杂**物被**鱼**干随意堆放( ~~简称**杂鱼**~~ ~
- 一个“此页面正在 **施工中……** 的标志牌⚠”(虽然鱼干不觉得有谁会看见,但万一呢……

{% endnote %}
templates-for-hexo.md
1
{% tpl constructing %}

效果如下

“请、、请您稍等!!就、、就快好了!”鱼干抱住,并企图藏住这个页面,说道。

(才不是没写完就发出来了

此页面正在 施工中……

您可能会看见 如下内容 出现在此页面中:

  • 一只忘记带安全帽的鱼干(只是是找不到了而已
  • 一些物被干随意堆放( 简称杂鱼 ~
  • 一个“此页面正在 施工中…… 的标志牌⚠”(虽然鱼干不觉得有谁会看见,但万一呢……

“请、、请您稍等!!就、、就快好了!”鱼干抱住,并企图藏住这个页面,说道。

(才不是没写完就发出来了

此页面正在 施工中……

您可能会看见 如下内容 出现在此页面中:

  • 一只忘记带安全帽的鱼干(只是是找不到了而已
  • 一些物被干随意堆放( 简称杂鱼 ~
  • 一个“此页面正在 施工中…… 的标志牌⚠”(虽然鱼干不觉得有谁会看见,但万一呢……

一些问候语,也许可以安放在网页的某个角落…?

  • 早喵~ 今天也是充满活力的一天呢~ (=^・ω・^=)
  • 午安~ 想干点什么嘛~ (,,>ω<,,)
  • 晚上好~ 累了嘛?鱼干会一直在你身边哦ฅ^⩊^ฅ
  • 夜深了~ 想要来鱼干的被窝玩嘛 ~ (⁄ ⁄•⁄ω⁄•⁄ ⁄)
  • 早点睡哦~ 熬夜对健康不好(比叉)
0%