python spyder怎么导入模块?

python spyder怎么导入模块?,第1张

Spyder是Python的IDE,很方便,您下载Anaconda并安装,Anaconda是完全免费的,包换很多Python依赖包.Anaconda带有Spyder3.0。安装完毕后在开始菜单中启动Anaconda Prompt,在其中输入spyder就可以启动了。在import之前,你可以 import sys sys.path.append('你的module的目录‘)就可以import这个目录里的module了。

Spyder is the Scientific PYthon Development EnviRonment:

a powerful interactive development environment for the Python language with advanced editing, interactive testing, debugging and introspection features

and a numerical computing environment thanks to the support of IPython (enhanced interactive Python interpreter) and popular Python libraries such as NumPy (linear algebra), SciPy (signal and image processing) or matplotlib (interactive 2D/3D plotting).

Spyder may also be used as a library providing powerful console-related widgets for your PyQt-based applications – for example, it may be used to integrate a debugging console directly in the layout of your graphical user interface.

方法1:通过函数append进行添加,如下所示:

import sys

sys.path

sys.path.append("S:\\Python\\Anaconda\\InstallPath\\envs\\Pytorch\\Lib\\site-packages")

但此方法存在一个问题,每次新建一个.py文件都需要添加这句话,比较繁琐;

方法2:添加一个.pth文件,并将该文件放置某个位置

设置spyder的目录的方法:1、点击菜单栏中的Tools选项,接着点击Current working directory选项;2、勾选The following directory选项;3、设置需要的目录路径即可。

具体方法:

(推荐教程:Python入门教程)

首先打开spyder,依次点击菜单栏中的Tools--->Preferences--->Current working directory选项;

然后在右侧勾选The following directory 选项,设置需要的目录即可。


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/bake/11537489.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-16
下一篇2023-05-16

发表评论

登录后才能评论

评论列表(0条)

    保存