pycharm

“UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.” when plotting figure with pyplot on Pycharm

隐身守侯 提交于 2020-02-26 05:12:28
问题 I am trying to plot a simple graph using pyplot, e.g.: import matplotlib.pyplot as plt plt.plot([1,2,3],[5,7,4]) plt.show() but the figure does not appear and I get the following message: UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure. I saw in several places that one had to change the configuration of matplotlib using the following: import matplotlib matplotlib.use('TkAgg') import matplotlib.pyplot as plt I did this, but then got an

Python中执行系统命令的四种方法

拈花ヽ惹草 提交于 2020-02-25 20:47:08
一、os.system方法 在子终端运行系统命令,可以获取命令执行后的返回信息以及执行返回的状态。执行后返回两行结果,第一行是结果, 第二行是执行状态信息,如果命令成功执行,这条语句返回0,否则返回1。 import os print(os.system('date')) 由于python3默认采用了UTF-8编码,而WIN8的CMD窗口采用的是GBK编码,导致了编码不同。 但是,如果简单的通过encode('gbk')之类的方法,不能解决根本问题。 尤其是当我们根本不是使用print命令来输出,而是控制台默认输出的情况下,是没办法修改os.system的编码格式的,因为os.system执行命令返回的并不是命令中出现的文本,而是一个int,为0时表示成功,为1时表示异常。 Pycharm下的解决方法: 二、os.popen方法 os.popen()方法不仅执行命令而且返回执行后的信息对象(常用于需要获取执行命令后的返回信息),是通过一个管道文件将结果返回。 import os os.popen() 专门建立的Python学习扣QUN:⑦⑧④⑦⑤⑧②①④ 从零基础开始到Python各领域的项目实战教程、开发工具与电子书籍。与你分享企业当下对于python人才需求及学好python的高效技巧,不停更新最新教程! 三、commands模块 -- 说明 getoutput

PyCharm中Directory与Python package的区别

扶醉桌前 提交于 2020-02-25 18:54:53
对于 Python 而言,有一点是要认识明确的, python 作为一个相对而言轻量级的,易用的脚本语言(当然其功能并不仅限于此,在此只是讨论该特点),随着程序的增长,可能想要把它分成几个文件,以便逻辑更加清晰,更好维护,亦或想要在几个程序中均使用某个函数,而不必将其复制粘贴到所有程序中。 为了支持这一点,Python有一种方法将定义函数放在一个文件中,并在脚本中使用它们,这样的文件叫做模块,一个模块中的定义可以被导入到其他模块,或者主模块中。 简单来说在python中模块就是指一个py文件,如果我们将所有相关的代码都放在一个py文件中,则该py文件既是程序由是模块,但是程序和模块的设计目的是不同的,程序的目的是为了运行,而模块的目的是为了其他程序进行引用 Dictionary Dictionary在pycharm中就是一个文件夹,放置资源文件,对应于在进行JavaWeb开发时用于放置css/ js 文件的目录,或者说在进行物体识别时,用来存储背景图像的文件夹。该文件夹其中并不包含_ _ init.py_ _文件 Python package 对于Python package 文件夹而言,与Dictionary不同之处在于其会自动创建_ _ init.py_ _文件。 简单的说,python package就是一个目录,其中包括一组模块和一个_ _ init.py_ _文件。

安装pycharm

泪湿孤枕 提交于 2020-02-25 18:31:48
下载软件包 找到arm64架构的版本pycharm下载:pycharm-community-2019.3.1.tar.gz 解压在bin目录下执行pycharm.sh即可,如果没有JDK会提示安装JDK。 安装JDK sudo add-apt-repository ppa:webupd8team/java sudo apt-get update apt search jdk # 搜索JDK安装包,可以看到openjdk-8-jdk/... arm64 OpenJDK Development Kit(JDK) sudo apt install openjdk-8-jdk export JAVA_PATH=/usr/lib/jvm/java-8-openjdk-arm64/bin 来源: oschina 链接: https://my.oschina.net/u/4228078/blog/3159932

pycharm 安装和首次使用

…衆ロ難τιáo~ 提交于 2020-02-25 14:41:31
由于本人也是开发语言的学习小白,所以对于开发时使用的工具也不算太熟悉,不过这里还是要推荐一下本人使用过 的两款工具: 1、pycharm ;2、eclipse 这是我用的比较顺手的两个工具当然这两个各有各的好处,这个还是交给各位自行去体会吧!本人认为只要自己使用的顺手即可 今天的内容主要讲解一下pycharm的安装和首次使用时的安装配置! 一、安装 1、从官网下载最新的pycharm版本:https://www.jetbrains.com/pycharm/download/download-thanks.html?platform=windows&code=PCC 点击之后会自动进行下载 2、下载完成后,直接双击下载好的exe文件进行安装,安装截图如下: 点击Next进入下一步: 点击Next进入下一步: 点击Install进行安装 安装完成后出现下图界面,点级Finish结束安装 二、安装完成后首次配置 1、首次打开如下图: 2、点击Create New Project,进入如下图的界面,图中的Location是选择你安装的python的位置,选择好后,点击create 3、在进入的界面如下图,鼠标右击图中箭头指向的地方,然后最后选择python file,在弹出的框中填写文件名(任意填写) 4、创建test文件打印hello world!,如下: ***************

PyCharm设置字体大小(亲测)

China☆狼群 提交于 2020-02-25 00:36:08
其实Pycharm的setting与IDEA的风格一样 登录进入Pycharm主页 打开Pycharm,点击左上角的File,选择Settings…… 选择Editor下的Font 根据表格中字体大小,调整size,到合适大小,点击右下角的apply按钮即可 点赞 ———————————————— 版权声明:本文为CSDN博主「风儿吹花儿美」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。 原文链接:https://blog.csdn.net/yangschfly/article/details/81660667 来源: CSDN 作者: gb4215287 链接: https://blog.csdn.net/gb4215287/article/details/104480764

How to run code in Pycharm

点点圈 提交于 2020-02-24 01:02:06
问题 If I go to "tools" and select "python console", and enter several lines of code, how do I execute this? If my cursor is at the end of the script, I can just hit enter. But how can I run the code using keyboard shortcuts if the cursor is not at the end? In Spyder this is done using shift+enter, but I can't figure out how to do it here. I've seen places say control+enter, but that doesn't work. Thanks! 回答1: If you use Win 10, 64Bits. Run your codes using Ctrl + Shift + F10 or simply right click

How to run code in Pycharm

£可爱£侵袭症+ 提交于 2020-02-24 01:01:46
问题 If I go to "tools" and select "python console", and enter several lines of code, how do I execute this? If my cursor is at the end of the script, I can just hit enter. But how can I run the code using keyboard shortcuts if the cursor is not at the end? In Spyder this is done using shift+enter, but I can't figure out how to do it here. I've seen places say control+enter, but that doesn't work. Thanks! 回答1: If you use Win 10, 64Bits. Run your codes using Ctrl + Shift + F10 or simply right click

How to run code in Pycharm

笑着哭i 提交于 2020-02-24 01:01:07
问题 If I go to "tools" and select "python console", and enter several lines of code, how do I execute this? If my cursor is at the end of the script, I can just hit enter. But how can I run the code using keyboard shortcuts if the cursor is not at the end? In Spyder this is done using shift+enter, but I can't figure out how to do it here. I've seen places say control+enter, but that doesn't work. Thanks! 回答1: If you use Win 10, 64Bits. Run your codes using Ctrl + Shift + F10 or simply right click

pip安装了包但pycharm里找不到

北战南征 提交于 2020-02-23 12:07:25
  使用pip install scipy安装了scipy1.2.3,但是打开pycharm里import还是报错,打开pycharm设置,里面的解释器里也找不到所需的包。   原因:安装了anaconda,解释器使用的是anaconda的python      但实际上pip安装到了系统里的解释器中 解决方案:   1.不使用anaconda的解释器,使用原系统的解释器。   2.如果就要在anaconda下安装,用pip安装的时候就需要修改安装路径     pip install --target=“ 目标路径” 工具包名字     目标路径为anaconda-lib-python版本-site-packages     如果使用pip安装过程中,下载东西总是断掉,可以考虑更换为国内源:          https://blog.csdn.net/loyachen/article/details/52996216      安装完后,在site-packages文件夹下可以找到新安装的包了。同时在pycharm设置的解释器里也可以找到了: 来源: https://www.cnblogs.com/sssssaylf/p/12342548.html