草庐IT

sys-package-mgr

全部标签

python - Mac 操作系统, pip : specify compiler for packages containing C libraries

我在使用pip使用默认的clang编译器编译mapscript(是来自pypi的包含C代码的包)时遇到了一些问题。这是我的尝试:-$sudopipinstallmapscriptPassword:Downloading/unpackingmapscriptRunningsetup.pyegg_infoforpackagemapscriptRequirementalreadysatisfied(use--upgradetoupgrade):distributein/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib

python - "PermissionError: [Errno 13] Permission denied: '/usr/lib/python3.5/site-packages '"安装Django

我无法在Ubuntu上安装基本的Django包。我刚刚删除了virtualenv并重新制作了它。pip3install=pip3install-rrequirements.txt[mything]cchilders@cchilders-desktop:~/projects/mything(master)$catrequirements.txtDjango==1.10.1django-filterdjangorestframeworkpsycopg2twilioipdbipython[mything]cchilders@cchilders-desktop:~/projects/mythi

python - 从 Python 解释器运行时获取 "ImportError: attempted relative import with no known parent package"

我正在使用Flask创建模块化应用blueprints特征。结果,我的目录结构是这样的:project__init__.pyconfig.pymould.pymodules__init__.pycore__init__.pycore.pydb.pymodels.py不要将此处的模块目录与Python模块混淆,它们用于为我的项目提供模块化结构(核心模块、foo模块、bar模块等)。现在,模块目录中的每个文件夹(以及其中的同名模块,例如core.core)都动态导入到我的主flask应用程序(mould.py)中这样做:foriteminos.listdir("modules"):ifno

python - python2 存在 site-packages 文件夹,python3 不存在

作为root用户,我看到:root@5d6f29f1d4e9:/usr/local/lib/python2.7#ls-a...dist-packagessite-packagesroot@5d6f29f1d4e9:/usr/local/lib/python3.6#ls-a...dist-packages当我运行这个时:find/-typed-name'site-packages'唯一的结果是:/usr/local/lib/python2.7/site-packages有谁知道为什么我在3.6中看不到站点包?我安装了python3:aptinstall-ybuild-essentiall

python - 为什么在 Python 3 的 'sys.modules' 中没有导入模块?

我正在阅读howtocheckifapythonmodulehasbeenimported说明似乎很清楚,请检查sys.modules中的模块.这与我在Python2中预期的一样有效,但不适用于Python3(已测试3.5和3.6)。例如:python3.6>>>importsys>>>'itertools'insys.modulesTruepython2.7>>>importsys>>>'itertools'insys.modulesFalse我注意到,itertools在Python3中被描述为“内置”sys.modulesdict(),而不是在Python2中,所以也许这就是它在

python - 在 pyqt 中将 sys.exit() 与 app.exec_ 一起使用

谁能解释一下使用sys.exit(app.exec_())而不是更简单的app.exec_()在PyQt中启动GUI的相对优点?我是PyQt的新手并且已经看过这两个示例。 最佳答案 当Unix风格的应用程序退出时,theyreturnanumbertotheirparentprocess称为“状态代码”或“退出状态”。0用于表示成功;任何非零值都是失败的。(有一些尝试standardisethemeaningoferrorcodes,但它通常仍然留给每个程序。)app.exec_()runsyourmainloop,andretur

python - 为什么 python 的 sys.path 中的第一个元素是空字符串?

我注意到,当我启动pythonREPL并执行以下操作时:importsysprint(sys.path)列表的第一个元素是一个空字符串。这只发生在REPL中。 最佳答案 sys.path[0]是由Python可执行文件创建的条目,用于引用正在运行的脚本的目录。如果没有脚本正在运行,例如REPL已被直接调用,添加了一个表示当前目录的空条目。 关于python-为什么python的sys.path中的第一个元素是空字符串?,我们在StackOverflow上找到一个类似的问题:

python - sys.stdin.readline() 和 input() : which one is faster when reading lines of input, 为什么?

当我需要从STDIN获取输入行时,我正在尝试决定使用哪一个,所以我想知道在不同情况下我需要如何选择它们。我发现以前的帖子(https://codereview.stackexchange.com/questions/23981/how-to-optimize-this-simple-python-program)说:HowcanIoptimizethiscodeintermsoftimeandmemoryused?NotethatI'musingdifferentfunctiontoreadtheinput,assys.stdin.readline()isthefastestonewh

Collecting package metadata (repodata.json): failedCondaSSLError: Encountered an SSL error. 一招解决

Collectingpackagemetadata(repodata.json):failedCondaSSLError:EncounteredanSSLerror.Mostlikelyacertificateverificationissue.先找到你的anaconda安装的位置,按照D:\Anaconda\Library\bin这个路径,复制bin文件下的这两个文件粘贴到D:\Anaconda\DLLs里面接着重启电脑就OK了

python - 如何使 sys.argv 参数可选?

sys.argv在运行程序时在shell命令行中获取参数。如何使这些参数可选?我知道我可以使用try-except。但这会强制您要么不插入额外参数,要么插入所有额外参数,除非您嵌套更多try-except这会使代码看起来更难阅读。编辑假设我想要以下功能,我该如何实现?$pythonprogram.pyaddPeter'Peter'wasaddedtothelistofnames.这个add参数(而不是--add)是可选的$pythonprogram.py只是正常运行程序。 最佳答案 编辑解决您的编辑问题,importsyssys.a