我已经开始使用我的Mac来安装Python软件包,就像我在工作时使用Windows PC一样; 但是在我的Mac上,我在写入日志文件或站点包时遇到了频繁的权限被拒绝错误.
因此我考虑过运行pip install <package>
,sudo
但考虑到我只是希望将其安装在我当前的用户帐户下,这是一个安全/可接受的sudo使用方法吗?
来自日志文件I/O错误的示例回溯:
Command /usr/bin/python -c "import setuptools;__file__='/Users/markwalker/build/pycrypto/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /var/folders/tq/hy1fz_4j27v6rstzzw4vymnr0000gp/T/pip-k6f2FU-record/install-record.txt failed with error code 1 in /Users/markwalker/build/pycrypto
Storing complete log in /Users/markwalker/Library/Logs/pip.log
Traceback (most recent call last):
File "/usr/local/bin/pip", line 8, in <module>
load_entry_point('pip==1.1', 'console_scripts', 'pip')()
File "/Library/Python/2.7/site-packages/pip-1.1-py2.7.egg/pip/__init__.py", line 116, in main
return command.main(args[1:], options)
File "/Library/Python/2.7/site-packages/pip-1.1-py2.7.egg/pip/basecommand.py", line 141, in main
log_fp = open_logfile(log_fn, 'w')
File "/Library/Python/2.7/site-packages/pip-1.1-py2.7.egg/pip/basecommand.py", line 168, in open_logfile
log_fp = open(filename, mode) …
Run Code Online (Sandbox Code Playgroud) 如果认为我的问题非常明显,几乎每个与之合作的开发人员UserProfile
都应该能够回答它.
但是,我在django文档或Django Book中找不到任何帮助.
如果你想UserProfile
用Django Forms 做一个表单,你想要修改配置文件字段以及一些User
字段.
但是没有forms.UserProfileForm
(还有?)!
你是怎样做的?
为了学习ArchLinux,我在VirtualBox机器上安装并使用了ArchLinux.它完美运行.现在我在我的电脑上安装了Docker(Windows环境).在安装Docker的过程中,我得到了一个警告,如果我在Windows上安装Docker,VirtualBox就无法启动我的机器......
我卸载了Docker并希望我仍然可以使用我的ArchLinux.但我不能!
有谁知道该怎么做,再次正确运行VirtualBox和机器?
经过长时间搜索postgre,关于manage.py killorphant,关于django_site,没有什么能帮助我解决这个错误:
Synchronizing apps without migrations:
Creating tables...
Installing custom SQL...
Installing indexes...
Running migrations:
Applying sites.0002_auto_20150929_1444...Traceback (most recent call last):
**File "/var/www/webapps/lib/python3.4/site-packages/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
psycopg2.ProgrammingError: must be owner of relation django_site**
Run Code Online (Sandbox Code Playgroud)
上述异常是以下异常的直接原因:
Traceback (most recent call last):
File "./manage.py", line 11, in <module>
execute_from_command_line(sys.argv)
File "/var/www/webapps/lib/python3.4/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/var/www/webapps/lib/python3.4/site-packages/django/core/management/__init__.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/var/www/webapps/lib/python3.4/site-packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File "/var/www/webapps/lib/python3.4/site-packages/django/core/management/base.py", line 338, in execute
output = …
Run Code Online (Sandbox Code Playgroud) 我一直在寻找django admin中的文档,search_fields
试图允许搜索相关字段.
所以,这是我的一些模型.
# models.py
class Team(models.Model):
name = models.CharField(max_length=255)
class AgeGroup(models.Model):
group = models.CharField(max_length=255)
class Runner(models.Model):
"""
Model for the runner holding a course record.
"""
name = models.CharField(max_length=100)
agegroup = models.ForeignKey(AgeGroup)
team = models.ForeignKey(Team, blank=True, null=True)
class Result(models.Model):
"""
Model for the results of records.
"""
runner = models.ForeignKey(Runner)
year = models.IntegerField(_("Year"))
time = models.CharField(_("Time"), max_length=8)
class YearRecord(models.Model):
"""
Model for storing the course records of a year.
"""
result = models.ForeignKey(Result)
year = …
Run Code Online (Sandbox Code Playgroud) 当实现一个接受指针参数包的函数时Ts...
,为什么我const
不能对指针进行限定,正如常规参数一样?
我在最新的GCC和Clang上遇到了不匹配的签名错误,我不明白为什么,因为指针const
只是一个实现细节(因此它对于常规参数是合法的).
template<typename... Ts>
class C
{
void f(int*);
void g(Ts*...);
};
template<typename... Ts>
void C<Ts...>::f(int* const) {} // Legal
template<typename... Ts>
void C<Ts...>::g(Ts* const...) {} // Compiler error
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
prog.cc:12:16: error: out-of-line definition of 'g' does not match any declaration in 'C<Ts...>'
void C<Ts...>::g(Ts* const...) {}
^
1 error generated.
Run Code Online (Sandbox Code Playgroud)
您还可以在此处查看代码和错误.
我正在尝试制作一个表单应用程序,但我不明白错误:
TypeError: object.__init__() takes exactly one argument (the instance to initialize)
Run Code Online (Sandbox Code Playgroud)
代码在这里;
class Myapp(App):
def build(self):
return Grid1()
class Grid1(GridLayout):
def __init__(self,**kwargs):
super(Grid1,self).__init__(**kwargs)
self.cols=1
self.inside=GridLayout()
self.inside.cols=2
self.inside.add_widget(Label(text="Your name is :"))
self.name=TextInput(multiline=False)
self.inside.add_widget(self.name)
self.inside.add_widget(Label(text="Your Last name is :"))
self.lastname=TextInput(multiline=False)
self.inside.add_widget(self.lastname)
self.inside.add_widget(Label(text="Your email is :"))
self.email=TextInput(multiline=False)
self.inside.add_widget(self.email)
self.submit=Button(text="Submit",font=40)
self.add_widget(self.submit)
if __name__=="__main__":
Myapp().run()
Run Code Online (Sandbox Code Playgroud)
File ".\kivyprima.py", line 38, in <module> Myapp().run()
File "C:\Users\Alex\AppData\Local\Programs\Python\Python37\lib\site-packages\kivy\app.py", line 829, in run root = self.build()
File ".\kivyprima.py", line 10, in build return Grid1()
File ".\kivyprima.py", line 34, in …
Run Code Online (Sandbox Code Playgroud) 我正在努力扩展ANT构建脚本以允许TeamCity构建代理运行Selenium测试.
这样做有一个服务器需要从selenium开始,最后没有关闭.所以我添加了一个额外的目标来在每个TC构建结束时对exe名称执行taskkill.
taskkill是否需要exe的绝对路径,因为以下内容不起作用;
<target name="shutdown.server" depends="init.properties" description="Shutdown the server after Selenium">
<exec osfamily="windows" executable="cmd.exe" spawn="true">
<arg line="taskkill /f /t /im app.exe"/>
</exec>
</target>
Run Code Online (Sandbox Code Playgroud)
这个过程似乎有几个孩子,这就是为什么我已经离开,/f /t
但正如我所说,他们当中没有一个关闭.
我正在使用PyQt应用程序,该应用程序使用Django将其内容提供给桌面用户.
在最新的更新中,我们有Django存储在数据库中的陈旧内容类型,并且在应用程序启动时,South的migrate或syncdb提供删除它们.是否可以通过调用migrate/syncdb来自动删除这些内容?
由于显而易见的原因,此提示无法向最终用户公开,所以我真的希望有一些方法可以让我们自动开车:)
我已经看到,在南迁移你可以打电话,--noinput
但不会删除它们,如果我们可以做到这一点会很好,因为我们知道这将是安全的.
我正在尝试将我的数据库(sqlite3)转储到一个夹具的json文件,但是我有一个非托管模型导致no such table
错误(显然!)所以你如何在db中使用这些模型dumpdata?
模型:
from django.db import models
class Backup(models.Model):
"""
This class is lazily recycled between various forms that ask the user to
provide a path to some data.
"""
dbloc = models.CharField(
max_length = 255
)
class Meta:
app_label = 'myApp'
db_table = 'backup'
managed = False
Run Code Online (Sandbox Code Playgroud)
错误:
CommandError: Unable to serialize database: no such table: backup
django ×5
python ×4
windows ×2
ant ×1
archlinux ×1
build ×1
c++ ×1
c++11 ×1
command-line ×1
const ×1
django-forms ×1
django-south ×1
docker ×1
dumpdata ×1
kivy ×1
macos ×1
pip ×1
postgresql ×1
profile ×1
sqlite ×1
sudo ×1
virtualbox ×1