到目前为止,我已经测试了各种方法来管理 Python中的项目依赖项:
我对所有这些问题(除了1.)的问题在于我的硬盘空间填充速度非常快:我不是开发人员,我使用Python进行日常工作.因此,我有数百个小项目都在做他们的事情.不幸的是,项目的80%,我需要"大"套餐:numpy
,pandas
,scipy
,matplotlib
-你的名字.典型的小项目大约有1000到2000行代码,但在venv/virtualenv/pipenv中有800MB的包依赖性.实际上我有大约100多GB的硬盘充满了python虚拟依赖项.
而且,在每个虚拟环境中安装所有这些都需要时间.我在Windows中工作时,许多包不能被轻易从Windows安装点子:Shapely
,Fiona
,GDAL
-我需要预编译的车轮克里斯托夫Gohlke.这很容易,但它会破坏大多数工作流程(例如,pip install -r requirements.txt
或pipenv install
来自pipfile).我觉得我40%安装/更新包依赖,只有60%的时间编写代码.此外,没有这些包管理真正与出版和测试代码的帮助,所以我需要其他工具如setuptools
,tox
,semantic-release
,twine
...
我和同事们聊过,但他们都面临着同样的问题,似乎没有人能找到真正的解决方案.我在想,如果有有一些包,例如,你在大多数项目中,全球范围内安装使用的那些的方法-例如numpy
,pandas
,scipy
,matplotlib
将在PIP安装C:\Python36\Lib\site-packages
或使用conda
中C:\ProgramData\Miniconda3\Lib\site-packages
-这些都是非常发达的包不经常打破一切.如果,我想在我的项目中很快解决这个问题.
其他的事情会去当地的virtualenv文件夹-我很想我的当前工作流从移动pipenv
到conda
.
这种方法有意义吗?至少最近在python中有很多开发,也许还有一些我还没看到的东西.是否有任何的最佳实践指导设置如何文件这样的混合全局-局部环境,例如,如何维护setup.py
,requirements.txt
或pyproject.toml
通过Gitlab,Github上共享等发展项目?有什么陷阱/警告?
克里斯·沃里克(Chris Warrick)的这篇精彩博文也完全解释了这一点.
我在 docker 容器中从主机挂载目录时遇到问题:
这是一个全栈情况:我正在使用服务堆栈来使文件在本地 LAN 上可用。该堆栈使用 nginx:alpine,图像可用 - 所以我无法轻松修改 Dockerimage。
有什么办法可以让 Alpine Linux 映像内的 xfs 无法获取用户和组 ID 33?
我尝试在 中设置 PUID 和 PGID docker-compose.yml
,但它不起作用(我也很难理解这一点):
services:
celeryworker:
environment:
- PUID=33
- PGID=33
Run Code Online (Sandbox Code Playgroud)
最小可重现示例:
主机上的文件:services:
celeryworker:
environment:
- PUID=33
- PGID=33
Run Code Online (Sandbox Code Playgroud)
docker-compose.yml
cd /mnt/nfs/folder1
ls -alh
>-rwxr-xr-x 1 www-data www-data 3.5M Sep 21 15:41 '02 - track.mp3'
ls -alhn
>-rwxr-xr-x 1 33 …
Run Code Online (Sandbox Code Playgroud) 我有一个简单的数据框,其中包含我想使用 hvpolot.heatmap 进行可视化的列和行。我可以做一些非常相似的事情:
df.style.background_gradient(cmap='summer')
Run Code Online (Sandbox Code Playgroud)
数据框非常简单:
> df.index
Index(['ackerland', 'friedhof', 'gartenland', 'gehoelz', 'golfplatz',
'gruenland', 'heide', 'kleingarten', 'laubholz', 'mischholz', 'moor',
'nadelholz'],
dtype='object')
> df.columns
Index(['hiking', 'biking', 'walking', 'sport', 'friends', 'family', 'picnic'], dtype='object')
Run Code Online (Sandbox Code Playgroud)
但是当我这样做时:
>import hvplot.pandas
>df.hvplot.heatmap(colorbar=True)
ValueError: Dimensions must be defined as a tuple, string, dictionary or Dimension instance, found a NoneType type.```
Run Code Online (Sandbox Code Playgroud)
这也不起作用:
>df.hvplot.heatmap(x=df.index, y=df.columns, colorbar=True)
ValueError: The truth value of a Index is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
Run Code Online (Sandbox Code Playgroud)
我已经阅读了大多数关于此的文档,但仍然不完全理解如何在 hvplot/holoviews/bokeh 中为 Pandas 数据框指定值维度: …
我使用Visual Studio已有很长时间了,但是维护变得太复杂了。现在,我尝试转向VS Code,但是它抛出了许多PyLint错误消息,这些消息对我来说没有意义(并且程序仍然可以按预期运行)。这些错误主要发生在从GoogleProtoBuf结构生成的Python代码中。
例如:
from lbsnstructure.lbsnstructure_pb2 import lbsnPost
def geoaccuracy_within_threshold(post_geoaccuracy, min_geoaccuracy):
"""Checks if geoaccuracy is within or below threshhold defined"""
if min_geoaccuracy == lbsnPost.LATLNG:
allowed_geoaccuracies = [lbsnPost.LATLNG]
elif min_geoaccuracy == lbsnPost.PLACE:
allowed_geoaccuracies = [lbsnPost.LATLNG, lbsnPost.PLACE]
elif min_geoaccuracy == lbsnPost.CITY:
allowed_geoaccuracies = [lbsnPost.LATLNG, lbsnPost.PLACE, lbsnPost.CITY]
else:
return True
# check post geoaccuracy
if post_geoaccuracy in allowed_geoaccuracies:
return True
else:
return False
Run Code Online (Sandbox Code Playgroud)
从pyLint引发错误消息E0602:
未定义变量'lbsnPost'pylint(E0602)
lbsnPost:GeneratedProtocolMessageType
但是,Google 明确声明这种形式的类型引用是正确的:
元类将枚举扩展为具有整数值的一组符号常量。因此,例如,常数addressbook_pb2.Person.WORK的值为2。
我在我的代码中都遇到了类似的错误(可以正常工作)。我怀疑这是我用错误的约定编写的内容,但是仍然可以使用。但是正确的约定是什么?
该页面似乎在讨论相同的问题,但是没有一种解决方案有效:
在PyDev
中使用协议缓冲区时,即使从导入中导入未定义的变量,即使这样做lbsnpost().LATLNG
(实例化protobuf消息),我也会得到相同的未定义的变量错误。
python ×2
bokeh ×1
conventions ×1
docker ×1
holoviews ×1
hvplot ×1
mount ×1
pandas ×1
permissions ×1
pylint ×1
python-3.x ×1