umap collectstatic 给出 "No such file or directory" 错误

umap collectstatic gives "No such file or directory" error

由于我对 Linux 知之甚少,我所能做的几乎就是从好的教程中复制和粘贴内容,在大多数情况下只是希望没有出错。我确实尝试过自己寻找解决方案并搜索互联网,但无济于事(我发现了很多非常相似的东西,但没有我理解的解决方案足以让我自己适应它来解决我的问题)。

我已经使用 this amazing tutorial and it works like a charm. Now I want to install umap, using this tutorial 安装了一个 osm tile 服务器。

一切正常,直到我到达 "umap collectstatic" 行。我得到的错误是:

 (venv) $ sudo umap collectstatic
 [sudo] Passwort für umap2: 

You have requested to collect static files at the destination
location as specified in your settings:

/home/ybon/.virtualenvs/umap/var/static

This will overwrite existing files!
Are you sure you want to do this?

Type 'yes' to continue, or 'no' to cancel: yes
Traceback (most recent call last):
File "/usr/local/bin/umap", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python2.7/dist-packages/umap/bin/__init__.py", line 12, in main
management.execute_from_command_line()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 359, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 294, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 345, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 193, in handle
collected = self.collect()
File "/usr/local/lib/python2.7/dist-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 115, in collect
for path, storage in finder.list(self.ignore_patterns):
File "/usr/local/lib/python2.7/dist-packages/django/contrib/staticfiles/finders.py", line 112, in list
for path in utils.get_files(storage, ignore_patterns):
File "/usr/local/lib/python2.7/dist-packages/django/contrib/staticfiles/utils.py", line 28, in get_files
directories, files = storage.listdir(location)
File "/usr/local/lib/python2.7/dist-packages/django/core/files/storage.py", line 399, in listdir
for entry in os.listdir(path):
OSError: [Errno 2] No such file or directory: '/home/ybon/Code/js/Leaflet.Storage'

现在,我发现某处配置文件中的设置可能有问题,但更改 local.py 中的目录 似乎没有做任何事情(就像我将它设置为 STATIC_ROOT = '/home/xxx_myusername_xxx/umap/var/static') - 我什至不知道这个“/home/ybon/Code/...”路径来自哪里!什么设置?

我确实没有在任何地方指定此路径!而且我的机器上确实找不到该文件夹​​。也许使用 virtualenv 以某种方式生成它,但我无法在我的机器上找到它,因为它是虚拟的(如 "not really there physically")但这只是一个非常疯狂的猜测,我真的不知道我在做什么谈论.

(我尝试了 运行 使用和不使用 sudo 的命令,它没有改变任何东西)。

一直想装一个tile server,今天也试过你们给的教程。所以我和你一样是个学习者!

使用教程 https://www.linuxbabe.com/linux-server/openstreetmap-tile-server-ubuntu-16-04 安装 Tile Server 非常简单。我只使用了 Rhineland Palatinate 的部分。

使用 Umap (https://umap-project.readthedocs.io/en/latest/ubuntu/#tutorial) 我遇到了一些问题。 1. 一个端口被使用了两次。我更改了 Apache 的端口。 2. 创建本地配置(wget https://raw.githubusercontent.com/umap-project/umap/master/umap/settings/local.py.sample -O /etc/umap/umap.conf)后,这个文件没有立即被识别。我通过在执行命令 "umap migrate" 之前更改文件来帮助自己。 我做了以下更改:

# For static deployment
STATIC_ROOT = '/etc/umap/var/static'

# For users' statics (geojson mainly)
MEDIA_ROOT = '/etc/umap/umap/var/data'

# Umap Settings
UMAP_SETTINGS='/etc/umap/umap.conf'

STATIC_ROOTMEDIA_ROOT 我已经更改了,因为用户 umap 拥有所有权限。然后我设置了环境变量UMAP_SETTINGS,否则找不到设置文件/etc/umap/umap.conf

(我也不知道这个“/home/ybon/Code/...”路径是从哪里来的。配置文件正确加载后,路径从配置文件加载。所以这并不重要不再。)

现在我可以毫无错误地使用以下命令:

(venv) $ umap collectstatic
Loaded local config from /etc/umap/umap.conf

You have requested to collect static files at the destination
location as specified in your settings:

    /etc/umap/var/static

This will overwrite existing files!
Are you sure you want to do this?

Type 'yes' to continue, or 'no' to cancel: yes
Copying '/srv/umap/venv/lib/python3.5/site-packages/umap/static/favicon.ico'
...
290 static files copied to '/etc/umap/var/static'.
(venv) $ umap storagei18n
Loaded local config from /etc/umap/umap.conf
Processing English
Found file /etc/umap/var/static/storage/src/locale/en.json
Exporting to /etc/umap/var/static/storage/src/locale/en.js
..
Processing Deutsch
Found file /etc/umap/var/static/storage/src/locale/de.json
..
Found file /etc/umap/var/static/storage/src/locale/sk_SK.json
Exporting to /etc/umap/var/static/storage/src/locale/sk_SK.js
(venv) $ umap createsuperuser
Loaded local config from /etc/umap/umap.conf
Username (leave blank to use 'umap'): 
Email address: 
Password: 
Password (again): 
Superuser created successfully.
(venv) $ umap runserver 0.0.0.0:8000
Loaded local config from /etc/umap/umap.conf
Loaded local config from /etc/umap/umap.conf
Performing system checks...

System check identified no issues (0 silenced).
April 09, 2018 - 14:02:15
Django version 1.10.5, using settings 'umap.settings'
Starting development server at http://0.0.0.0:8000/

终于可以使用umap了。