我有一个Django项目,我想在端口80运行manage.py runserver
。在我的项目中,我使用Wand库,并使用自制软件安装了freetype和imagemagick:
brew install freetype imagemagick
要在端口80 runserver
运行Django,需要使用sudo
运行,但是当我使用sudo
运行runserver时,它似乎找不到imagemagick:
$ sudo ~/.pyenv/versions/myproject/bin/python manage.py runserver 0.0.0.0:80
Password:
Performing system checks...
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x11068c840>
Traceback (most recent call last):
File "/Users/Oskar/.pyenv/versions/myproject/lib/python3.6/site-packages/wand/api.py", line 180, in <module>
libraries = load_library()
File "/Users/Oskar/.pyenv/versions/myproject/lib/python3.6/site-packages/wand/api.py", line 135, in load_library
raise IOError('cannot find library; tried paths: ' + repr(tried_paths))
OSError: cannot find library; tried paths: []
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/Oskar/.pyenv/versions/myproject/lib/python3.6/site-packages/django/utils/autoreload.py", line 228, in wrapper
fn(*args, **kwargs)
File "/Users/Oskar/.pyenv/versions/myproject/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 125, in inner_run
self.check(display_num_errors=True)
File "/Users/Oskar/.pyenv/versions/myproject/lib/python3.6/site-packages/django/core/management/base.py", line 359, in check
include_deployment_checks=include_deployment_checks,
File "/Users/Oskar/.pyenv/versions/myproject/lib/python3.6/site-packages/django/core/management/base.py", line 346, in _run_checks
return checks.run_checks(**kwargs)
File "/Users/Oskar/.pyenv/versions/myproject/lib/python3.6/site-packages/django/core/checks/registry.py", line 81, in run_checks
new_errors = check(app_configs=app_configs)
File "/Users/Oskar/.pyenv/versions/myproject/lib/python3.6/site-packages/django/core/checks/urls.py", line 16, in check_url_config
return check_resolver(resolver)
File "/Users/Oskar/.pyenv/versions/myproject/lib/python3.6/site-packages/django/core/checks/urls.py", line 26, in check_resolver
return check_method()
File "/Users/Oskar/.pyenv/versions/myproject/lib/python3.6/site-packages/django/urls/resolvers.py", line 254, in check
for pattern in self.url_patterns:
File "/Users/Oskar/.pyenv/versions/myproject/lib/python3.6/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/Users/Oskar/.pyenv/versions/myproject/lib/python3.6/site-packages/django/urls/resolvers.py", line 405, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/Users/Oskar/.pyenv/versions/myproject/lib/python3.6/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/Users/Oskar/.pyenv/versions/myproject/lib/python3.6/site-packages/django/urls/resolvers.py", line 398, in urlconf_module
return import_module(self.urlconf_name)
File "/Users/Oskar/.pyenv/versions/3.6.0/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 978, in _gcd_import
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
File "/Users/Oskar/git/myproject/myproject/urls.py", line 12, in <module>
from views import about, index, upload
File "/Users/Oskar/git/myproject/views.py", line 7, in <module>
from wand.image import Image
File "/Users/Oskar/.pyenv/versions/myproject/lib/python3.6/site-packages/wand/image.py", line 20, in <module>
from .api import MagickPixelPacket, libc, libmagick, library
File "/Users/Oskar/.pyenv/versions/myproject/lib/python3.6/site-packages/wand/api.py", line 206, in <module>
'Try to install:\n ' + msg)
ImportError: MagickWand shared library not found.
You probably had not installed ImageMagick library.
Try to install:
brew install freetype imagemagick
brew中的Imagemagick文件:
$ ls -l $(brew --prefix imagemagick)/lib
total 7904
drwxr-xr-x 4 Oskar admin 128 Nov 11 14:25 ImageMagick
-r--r--r-- 1 Oskar admin 553388 Nov 15 18:20 libMagick++-7.Q16HDRI.3.dylib
-r--r--r-- 1 Oskar admin 913560 Nov 11 14:25 libMagick++-7.Q16HDRI.a
lrwxr-xr-x 1 Oskar admin 29 Nov 11 14:25 libMagick++-7.Q16HDRI.dylib -> libMagick++-7.Q16HDRI.3.dylib
-rwxr-xr-x 1 Oskar admin 1272 Nov 15 18:20 libMagick++-7.Q16HDRI.la
-r--r--r-- 1 Oskar admin 1608056 Nov 15 18:20 libMagickCore-7.Q16HDRI.4.dylib
-r--r--r-- 1 Oskar admin 2321824 Nov 11 14:25 libMagickCore-7.Q16HDRI.a
lrwxr-xr-x 1 Oskar admin 31 Nov 11 14:25 libMagickCore-7.Q16HDRI.dylib -> libMagickCore-7.Q16HDRI.4.dylib
-rwxr-xr-x 1 Oskar admin 1144 Nov 15 18:20 libMagickCore-7.Q16HDRI.la
-r--r--r-- 1 Oskar admin 1109812 Nov 15 18:20 libMagickWand-7.Q16HDRI.4.dylib
-r--r--r-- 1 Oskar admin 1564192 Nov 11 14:25 libMagickWand-7.Q16HDRI.a
lrwxr-xr-x 1 Oskar admin 31 Nov 11 14:25 libMagickWand-7.Q16HDRI.dylib -> libMagickWand-7.Q16HDRI.4.dylib
-rwxr-xr-x 1 Oskar admin 1214 Nov 15 18:20 libMagickWand-7.Q16HDRI.la
drwxr-xr-x 10 Oskar admin 320 Nov 15 18:20 pkgconfig
所有libMagickWand dylib文件
$ sudo find / -name "libMagickWand*.dylib"
./usr/local/lib/libMagickWand-7.Q16HDRI.4.dylib
./usr/local/lib/libMagickWand-7.Q16HDRI.dylib
./usr/local/Cellar/imagemagick@6/6.9.9-9/lib/libMagickWand-6.Q16.dylib
./usr/local/Cellar/imagemagick@6/6.9.9-9/lib/libMagickWand-6.Q16.5.dylib
./usr/local/Cellar/imagemagick@6/6.9.9-11/lib/libMagickWand-6.Q16.dylib
./usr/local/Cellar/imagemagick@6/6.9.9-11/lib/libMagickWand-6.Q16.5.dylib
./usr/local/Cellar/imagemagick@6/6.9.9-20/lib/libMagickWand-6.Q16.dylib
./usr/local/Cellar/imagemagick@6/6.9.9-20/lib/libMagickWand-6.Q16.5.dylib
./usr/local/Cellar/imagemagick@6/6.9.9-21/lib/libMagickWand-6.Q16.dylib
./usr/local/Cellar/imagemagick@6/6.9.9-21/lib/libMagickWand-6.Q16.5.dylib
./usr/local/Cellar/imagemagick@6/6.9.9-19/lib/libMagickWand-6.Q16.dylib
./usr/local/Cellar/imagemagick@6/6.9.9-19/lib/libMagickWand-6.Q16.5.dylib
./usr/local/Cellar/imagemagick@6/6.9.9-10/lib/libMagickWand-6.Q16.dylib
./usr/local/Cellar/imagemagick@6/6.9.9-10/lib/libMagickWand-6.Q16.5.dylib
./usr/local/Cellar/imagemagick@6/6.9.9-17/lib/libMagickWand-6.Q16.dylib
./usr/local/Cellar/imagemagick@6/6.9.9-17/lib/libMagickWand-6.Q16.5.dylib
./usr/local/Cellar/imagemagick@6/6.9.9-12/lib/libMagickWand-6.Q16.dylib
./usr/local/Cellar/imagemagick@6/6.9.9-12/lib/libMagickWand-6.Q16.5.dylib
./usr/local/Cellar/imagemagick@6/6.9.9-15/lib/libMagickWand-6.Q16.dylib
./usr/local/Cellar/imagemagick@6/6.9.9-15/lib/libMagickWand-6.Q16.5.dylib
./usr/local/Cellar/imagemagick@6/6.9.9-23/lib/libMagickWand-6.Q16.dylib
./usr/local/Cellar/imagemagick@6/6.9.9-23/lib/libMagickWand-6.Q16.5.dylib
./usr/local/Cellar/imagemagick@6/6.9.9-14/lib/libMagickWand-6.Q16.dylib
./usr/local/Cellar/imagemagick@6/6.9.9-14/lib/libMagickWand-6.Q16.5.dylib
./usr/local/Cellar/imagemagick/7.0.7-11/lib/libMagickWand-7.Q16HDRI.4.dylib
./usr/local/Cellar/imagemagick/7.0.7-11/lib/libMagickWand-7.Q16HDRI.dylib
在另一个端口上没有sudo
的情况下运行此工作正常,我怎样才能使它在端口80上工作?
答案 0 :(得分:1)
imagemagick
次安装首先,last version of imagemagick
is currently not supported by wand
,因此如果您不使用它,可以安全地将其卸载,以避免干扰启动imagemagick@6
wand
$ brew uninstall imagemagick
}}:
imagemagick
这是可选的。
如果您要保留两个版本的安装,我仍然会取消wand
取消旧版dylib的链接,MAGICK_PATH
可以在我的计算机上运行而不设置$ brew unlink imagemagick
Unlinking /usr/local/Cellar/imagemagick/7.0.7-11... 72 symlinks removed
:
imagemagick@6
关联$ brew link imagemagick@6
Linking /usr/local/Cellar/imagemagick@6/6.9.9-23... 76 symlinks created
:
$ sudo python3.6 -c "from wand.image import Image"
检查这是否足够(正如我所说,此设置已在我的机器上运行):
MAGICK_PATH
如果没有出现错误,您就完成了!您也可以清除MAGICK_PATH
变量,因为它现在已经过时了。
您应该保留wand
,因为它是sudo
查找库的关键。要将var传播到sudo会话,请修改$ sudo visudo
设置:
Defaults env_keep += "MAGICK_PATH"
添加行MAGICK_PATH
,保存并退出。您可能需要启动新的终端会话才能使更改生效。这将确保将sudo
变量传递给body {margin: 0}
html, body {height: 100vh}
.container {
display: flex;
height: 100vh; /* mandatory (100% of the viewport height) */
background: #ddd;
opacity: 0.6;
}
.container > div {
flex: 1;
text-align: center;
transition: .3s;
max-width: 20%;
padding: 8em 0;
background: #000;
opacity: 0.9;
}
.container > div:hover {
transition: .5s;
max-width: 40%;
background: #333;
flex-grow: 2;
cursor: pointer;
color: #fff;
}
会话。
答案 1 :(得分:0)
将您环境的相关部分传播到root环境中:
crossjoin_df <- function(df1, df2, temp_col = ".k") {
# `$`(df1, temp_col) <- 1
df1 <- df1 %>%
mutate(!!temp_col := 1)
# `$`(df2, temp_col) <- 1
df2 <- df2 %>%
mutate(!!temp_col := 1)
left_join(df1, df2, by = temp_col) %>% select(-one_of(temp_col))
}
params <- data.frame(k = c(11,10),
n = c(27,26))
data <- data.frame(a = 1:3,
b = 4:6)
crossjoin_df(params, data)
# k n a b
#1 11 27 1 4
#2 11 27 2 5
#3 11 27 3 6
#4 10 26 1 4
#5 10 26 2 5
#6 10 26 3 6