Giter Site home page Giter Site logo

Comments (21)

SiyiZhao avatar SiyiZhao commented on June 13, 2024

控制台显示如下
image

from obsidian_vault_template_for_researcher.

sheldonxxd avatar sheldonxxd commented on June 13, 2024

中文注释报错,可以在 author_count.py 第一行新增内容:
# -- coding: utf-8 --

from obsidian_vault_template_for_researcher.

sheldonxxd avatar sheldonxxd commented on June 13, 2024

image

from obsidian_vault_template_for_researcher.

SiyiZhao avatar SiyiZhao commented on June 13, 2024

发现新的报错:
Screen Shot 2022-04-08 at 10 25 49

from obsidian_vault_template_for_researcher.

sheldonxxd avatar sheldonxxd commented on June 13, 2024

这可能与python版本有关,我使用的是python3.7.10。
image

注意到你使用的mac,或许可以再检查下 terminal 中默认的 python 版本?

from obsidian_vault_template_for_researcher.

SiyiZhao avatar SiyiZhao commented on June 13, 2024

terminal中的python版本是3.8.8,其它环境的python3也在3.8及以上。这句在vscode也能正常使用,不知道为什么报错……

from obsidian_vault_template_for_researcher.

sheldonxxd avatar sheldonxxd commented on June 13, 2024

你可以尝试使用 try...except 的方式看看,代码修改建议如下:
image

from obsidian_vault_template_for_researcher.

SiyiZhao avatar SiyiZhao commented on June 13, 2024

f-string的报错出现在了obs.py里……
image

from obsidian_vault_template_for_researcher.

sheldonxxd avatar sheldonxxd commented on June 13, 2024

看起来还是版本的问题。Templater插件调用了哪个python需要搞清楚。

你可以在 08-Assets/Scripts 目录下新建一个 test.py,填写以下内容:

import sys, platform
print('system:', platform.platform())
print('python_version:', sys.version_info)
print(sys.path)

然后到 Templater 插件设置中新增一个 user function:

image

再到 09-Templates 目录下新建一个模板「查看系统信息」,填写如下内容:

<% tp.user.show_python_version() %>

image

然后到任意一个草稿页面中按 Alt+E 插入上一步新建的「查看系统信息」模板,会出现以下信息:

image

即可查看被 Templater 真实调用的 python 版本情况。

from obsidian_vault_template_for_researcher.

sheldonxxd avatar sheldonxxd commented on June 13, 2024

在linux系统上测试也没有复现此问题,按照上述步骤操作结果如下:

system: Linux-5.13.19-2-MANJARO-x86_64-with-glibc2.33
python_version: sys.version_info(major=3, minor=9, micro=7, releaselevel='final', serial=0)
['/run/media/sheldonxxd/T7/projects/working/08-Assets/Scripts', '/usr/lib/python39.zip', '/usr/lib/python3.9', '/usr/lib/python3.9/lib-dynload', '/home/sheldonxxd/.local/lib/python3.9/site-packages', '/usr/lib/python3.9/site-packages']

linux 跟 macOS 可能更接近一点,且python版本到3.9.7也没有问题。上述结果可供参考。

from obsidian_vault_template_for_researcher.

SiyiZhao avatar SiyiZhao commented on June 13, 2024

插入模版后没有出现新的信息……请问是在源码模式下插入模版后就会自动出现吗?
另外我注意到在Templater 插件设置中新增 user function是用的是python开头,这会不会调用python2而不是python3呢?

from obsidian_vault_template_for_researcher.

sheldonxxd avatar sheldonxxd commented on June 13, 2024

是的,插入模板,会像下边这样:

show_python_version

关于 mac 中 python = python2,你可以试试修改下。

from obsidian_vault_template_for_researcher.

SiyiZhao avatar SiyiZhao commented on June 13, 2024

我在terminal中试过了,python默认是python3。
但是插入模版不能自动跳转,我尝试了其它用到tp的模版,插入后也不能自动更改。但从日程生成草稿是正常的……(如下图所示)
可以看一下您的template插件是如何设置的吗?

from obsidian_vault_template_for_researcher.

SiyiZhao avatar SiyiZhao commented on June 13, 2024

Screen Shot 2022-04-08 at 19 25 09

from obsidian_vault_template_for_researcher.

sheldonxxd avatar sheldonxxd commented on June 13, 2024

看上去是Templater插件的一个奇怪问题。

image

from obsidian_vault_template_for_researcher.

SiyiZhao avatar SiyiZhao commented on June 13, 2024

template设置没问题,但还是不能自动跳转……我仿照作者统计做了个按钮可以用,确实调取的是python2……
目前面临的新问题是,我的package装在anaconda里,请问template的user function可以像terminal中一样使用conda activate base吗?(我试了试好像不行……)
或者有没有办法在python脚本中指定解释器为anaconda中的python?

from obsidian_vault_template_for_researcher.

sheldonxxd avatar sheldonxxd commented on June 13, 2024

在 win11 系统中,在 templater 的 user function 中使用 conda activate base,Console 报错信息如下:

CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
If using 'conda activate' from a batch script, change your
invocation to 'CALL conda.bat activate'.

当按照提示修改为 CALL conda.bat activate base && python xyz.py 后问题消失。请查看 console 错误提示或可解决,祝好运!

from obsidian_vault_template_for_researcher.

SiyiZhao avatar SiyiZhao commented on June 13, 2024

两种命令都尝试了,没有报错,但是好像没有发挥作用……

from obsidian_vault_template_for_researcher.

sheldonxxd avatar sheldonxxd commented on June 13, 2024

image

建议在vscode中直接运行调试 author_count.py 代码,如上图所示,修改文件路径,然后运行即可。 调试方法见 issue #8

作者统计结果会打印在terminal,复制拷贝到笔记中也是一样的,此功能并不常用,只是帮助 follow 大牛新建其页面。

from obsidian_vault_template_for_researcher.

SiyiZhao avatar SiyiZhao commented on June 13, 2024

好的,感谢!

from obsidian_vault_template_for_researcher.

lute15 avatar lute15 commented on June 13, 2024

看起来还是版本的问题。Templater插件调用了哪个python需要搞清楚。

你可以在 08-Assets/Scripts 目录下新建一个 test.py,填写以下内容:

import sys, platform
print('system:', platform.platform())
print('python_version:', sys.version_info)
print(sys.path)

然后到 Templater 插件设置中新增一个 user function:

image

再到 09-Templates 目录下新建一个模板「查看系统信息」,填写如下内容:

<% tp.user.show_python_version() %>

image

然后到任意一个草稿页面中按 Alt+E 插入上一步新建的「查看系统信息」模板,会出现以下信息:

image

即可查看被 Templater 真实调用的 python 版本情况。

您好,我调用的版本时3.6,但是我也有3.8的版本
image

但我的c盘下也有别的python文件夹,这个要怎么处理?麻烦啦,新手小白一枚
image

from obsidian_vault_template_for_researcher.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.