简体   繁体   English

当我在Pycharm中创建新的python文件时,是否可以包含解释器路径(或设置任何默认代码)?

[英]Is it possible to include interpreter path (or set any default code) when I create new python file in Pycharm?

I haven't been able to find anything and I am not sure if this is the place I should be asking... 我什么都找不到,我不确定这是否是我要问的地方...

But I want to include the path to my interpreter in every new project I create. 但是我想在我创建的每个新项目中都包括解释器的路径。 The reason being is that I develop locally and sync my files to a linux server. 原因是我在本地开发并将文件同步到linux服务器。 It is annoying having to manually type #! /users/w/x/y/z/bin/python 不得不手动键入#! /users/w/x/y/z/bin/python很烦#! /users/w/x/y/z/bin/python #! /users/w/x/y/z/bin/python every time I create a new project. 每次创建新项目时, #! /users/w/x/y/z/bin/python Also would be nice to include certain imports I use 90% of the time. 包括我90%的时间使用的某些导入内容也很不错。

I got to thinking, in the program I produce music with you can set a default project file. 我想了一下,在程序中我制作音乐可以设置默认项目文件。 Meaning, when you click new project it is set up how you have configured (include certain virtual instruments, effects, etc). 意思是,当您单击新项目时,将设置您的配置方式(包括某些虚拟乐器,效果等)。

Is it possible to do this or something similar with IDE , and more specifically, Pycharm ? 是否可以执行此操作或使用IDE (或更具体地说,使用Pycharm)执行类似操作

You should open File in the main menu and click Default Settings , collapse the Editor then click File and Code Templates , in the Files tab click on the + sign and create a new Template , give the new template a name and extension, in the editor box put your template content, in your case #! /users/w/x/y/z/bin/python 您应该在主菜单中打开“ 文件 ,然后单击“ 默认设置” ,折叠编辑器,然后单击“ 文件和代码模板” ,在“ 文件”选项卡中,单击+号并创建一个新模板 ,并在编辑器中为新模板指定名称和扩展名。框放置您的模板内容,以您的情况#! /users/w/x/y/z/bin/python #! /users/w/x/y/z/bin/python apply and OK . #! /users/w/x/y/z/bin/python apply确定 After that everytime you open a project, select that template to include default lines you want. 之后,每次打开项目时,都选择该模板以包含所需的默认行。 You could make number of templates. 您可以制作许多模板。

单击带有项目名称的右上角选项卡,然后转到“ Edit Configurations ,您可以在其中更改解释器。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我已经正确设置了 PyCharm 解释器,但是当运行代码时,它显示在运行 window PyCharm 使用另一个 Z23EEEB4347BDD25DDAZBexe 之前使用9EEE73BDD25DDAZBexe。 - I have set PyCharm interpreter right but when run the code, it shows in the run window PyCharm uses another python.exe I used before 是否可以在 pycharm 的 python 中包含 c 代码? - Is it possible to include c code in python in pycharm? 将当前文件目录添加到 PyCharm 中的 Python 解释器路径 - Add current file directory to Python interpreter path in PyCharm 当我在 pycharm 上克隆一个 repo 时,我需要设置一个 python 解释器 - I need to set up an python interpreter when i clone a repo on pycharm 将 PyCharm Python 解释器设置为 Docker - Set PyCharm Python interpreter to Docker 设置默认解释器并在 PyCharm 2017 中不使用 virtualenv - Set a Default Interpreter and use NO virtualenv in PyCharm 2017 新用户的PyCharm:创建新的python文件? - PyCharm for new comers: create new python file? 如何通过python设置Pycharm输出路径文件 - How to set Pycharm output path file by python 如何在python可视化代码扩展中预选(设置默认)python解释器? - How to preselect (set default) python interpreter in python visual code extension? 在远程 python 3 解释器周围使用包装器时,如何在 Pycharm 中禁用 python 2.7 代码兼容性错误消息? - How can I disable python 2.7 code compatibility error message in Pycharm when using wrapper around remote python 3 interpreter?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM