Python
Python作为一门简单易学的编程语言,在当今深度学习的时代更是大焕光彩,该专栏聚焦Python学习过程中的重点和难点,让我们轻松掌握Python的基本用法并实践。
zhanghm1995
香港中文大学(深圳)在读博士生
展开
-
AttributeError: module ‘requests‘ has no attribute ‘get‘
问题描述执行python程序时报错:AttributeError: module 'requests' has no attribute 'get'解决方案原始的requests版本过低,我安装的是requests==2.22.0的版本,升级一下即可。pip install -U requests原创 2022-02-12 11:14:07 · 1522 阅读 · 0 评论 -
ImportError with scipy.misc cannot import toimage错误解决
问题描述在使用如下代码时出现错误:import scipy.miscscipy.misc.toimage(image_numpy).save(s, format="jpeg")错误提示:ImportError with scipy.misc cannot import toimage问题原因scipy库版本过高,在1.2版本以后就删除了这个函数。解决方案很多解决方案说是尝试降低scipy库版本,其实大可不必,官方都建议不用这个函数了,我们没必要反其道行之。我的解决方案:from原创 2022-01-16 20:02:14 · 580 阅读 · 0 评论 -
Windows下配置Python环境报错error: Microsoft Visual C++ 14.0 or greater is required. Get it with “Microsoft
问题描述在Windows 10下Anaconda环境中配置安装pycotools包时出现报错:error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft解决方案主要原因是我的Windows 10下缺少部分在安装Python包时需要进行C++编译的环境和依赖,因此需要进行下载和安装。打开该链接中点击下载生成工具:你就会下载得到一个名为vs_buildtools__396764696.163662原创 2021-11-15 21:34:30 · 2080 阅读 · 0 评论 -
ubuntu下conda在bash和zsh终端下的自动补全设置
背景Anaconda作为Python的包管理器非常好用,可以用来统一管理Python虚拟环境和包的安装,但是在使用过程中发现许多的conda命令并不能像使用Ubuntu其他命令一下通过按Tab自动补全,例如激活虚拟环境:conda activate cv-env如果没有自动补全功能,你就必须得全部手打出来上面的命令才行。这对我们的使用造成了很大不便。因此该篇博客的目的就是通过总结我找到的方法能够设置conda命令实现自动补全功能。zsh终端如果你使用的是zsh终端,你很有可能会用到on-my-原创 2021-08-31 09:35:37 · 3107 阅读 · 0 评论 -
Mayavi学习之旅——基础知识及学习资源
官网:https://docs.enthought.com/mayavi/mayavi/mayavi.mlab为脚本中绘图包:https://docs.enthought.com/mayavi/mayavi/mlab.html#simple-scripting-with-mlab所有函数索引为:https://docs.enthought.com/mayavi/mayavi/auto/mlab_reference.html#mlab-referenceimport numpy as npimpo原创 2021-06-27 09:25:03 · 1973 阅读 · 0 评论 -
pip install opencv-python出现ModuleNotFoundError: No module named ‘skbuild‘错误解决方案
pip install opencv-pythonTraceback (most recent call last): File "<string>", line 1, in <module> File "/tmp/pip-build-is7g9vyo/opencv-python/setup.py", line 9, in <module> import skbuild ModuleNotFoundError: No mo原创 2021-06-27 09:23:30 · 1391 阅读 · 0 评论 -
pip install列出待安装包的所有版本
问题描述一般我们在使用pip Install命令安装Python软件包的时候,会想知道能安装的包版本的是多少,这样方便自己选择可能的兼容版本进行安装,在pip某个版本之前获取待安装包的所有版本命令比较简单,直接用:pip install torch==就会列出所有torch版本,但最新版的pip不支持直接用上述命令查找所有torch的版本,会出现错误:ERROR: Could not find a version that satisfies the requirement torch==ERR原创 2021-05-30 13:49:56 · 2590 阅读 · 1 评论 -
UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show...问题
UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.plt.show()解决:pip install pyqt5https://stackoverflow.com/questions/41994485/how-to-fix-could-not-find-or-load-the-qt-platform-plugin-windows-while-usin原创 2021-03-23 00:06:00 · 754 阅读 · 1 评论 -
Python安装LLVMLite报错及解决方案
pip install llvmlite报错:Building wheels for collected packages: llvmlite Building wheel for llvmlite (setup.py) ... error ERROR: Command errored out with exit status 1: command: /home/z00520770/.virtualenvs/segmentation-python27/bin/python -u -c 'im原创 2021-02-01 22:23:23 · 9121 阅读 · 5 评论 -
Python学习之旅——虚拟环境的使用virtualenv和virtualenvwrapper
1、介绍Python作为一门解释性语言,其版本的更新和迭代非常快,并且Python2和Python3之间的语法和需要用到的库都不相同,因此在我们实际使用过程中就会经常遇到类似以下的问题:1、想要跑一个项目A,项目A需要Python2的环境,并且依赖numpy==1.16.6版本,这个时候我们可以直接执行pip2 install numpy==1.16.6给我们的系统Python2安装一个1.16.6版本的numpy,能够顺利运行项目A;2、这个时候又想要尝试一个新的项目B,项目B虽然也可以在Pytho原创 2020-09-12 08:56:55 · 733 阅读 · 0 评论 -
Python学习之旅——numpy库基础使用总结(超详细)
文章目录介绍基础用法矩阵创建矩阵运算矩阵解包常用内置函数np.asarray函数np.ascontiguousarray函数np.copy函数np.reshape函数np.where函数介绍基础用法矩阵创建numpy矩阵的类型为numpy.ndarray,全零矩阵:d = np.zeros(2)print(d, d.shape)d = np.zeros((2,1))print(d, d.shape)d = np.zeros((3,4))print(d, d.shape)# 下面原创 2020-09-05 11:54:28 · 668 阅读 · 0 评论 -
Python学习之旅——基础数据结构用法全貌
list列表tuple元组1、对元组中每个元素乘以一个倍数d = (2, 3)print(d)y = tuple(map(lambda x: x*2, d))print(y)字符串字符串格式化id_text = '{} {:.2f}'.format(10, 3.1415926)print(id_text)注意如何限定小数点位数。...原创 2020-07-18 09:31:06 · 141 阅读 · 0 评论 -
Ubuntu16.04下Python程序出现错误qt.qpa.plugin: Could not load the Qt platform plugin xcb解决方法
问题描述我在运行一个使用Pyqt5库的Python程序时,出现报错:qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this pr原创 2020-06-01 16:08:28 · 30043 阅读 · 30 评论 -
Ubuntu16.04更新Python3.5到Python3.7靠谱方法
步骤sudo add-apt-repository ppa:deadsnakes/ppasudo apt-get updatesudo apt-get install python3.7然后配合虚拟环境使用新版本的Python,不要做一些系统级的替换,容易出问题:mkvirtualenv python37 -p python3.7原创 2020-06-01 10:26:36 · 10679 阅读 · 7 评论 -
Python常用总结——捋一捋Python中经常遇到的知识点
函数*和**参数含义https://www.cnblogs.com/arkenstone/p/5695161.htmlPython函数参数包括位置参数、关键字参数*和**参数都用来接收未知数量的参数,*参数将接收的参数作为元组传入,**将关键字参数作为字典传入;def func(**kargs):print(type(kargs))a = kargs[“abc”]print(a)print(kargs[“name”])def func1(name, abc):print(abc)p原创 2020-05-28 23:06:13 · 253 阅读 · 0 评论 -
Ubuntu16.04中matplotlib显示中文字体乱码解决方案
网上教程很多,但也比较杂乱,因此本博文整理了一下我最终成功的方案,供大家参考。1、找到simhei.ttf文件在Windows系统C盘中搜索得到一个文件名叫simhei.ttf的简体字字体文件,这个文件在一般的Windows系统中都会有的,搜索一下耐心等待就有2、查看自己所用matplotlib库所在路径import matplotlibprint(matplotlib.matplotl...原创 2019-04-10 21:55:40 · 1505 阅读 · 1 评论 -
python模块搜索与导入过程及原理详解
python中,每个.py文件被称之为模块,每个具有__init__.py文件的目录被称为包。只要模块或者包所在的目录在sys.path中,就可以使用import 模块或import 包来使用 如果你要使用的模块(py文件)和当前模块在同一目录,只要import相应的文件名就好,比 如在a.py中使用b.py: import b 详细参考:https://blog.csdn.net...原创 2018-09-06 09:02:39 · 3705 阅读 · 1 评论