我过去和pip一起运气很好,但是在安装一些东西上工作让我有些头疼.我总是收到错误,比如找不到任何发行版的某些包在/root/.pip/pip.log中存储失败的调试日志
Could not find any downloads that satisfy the requirement somepackage
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-RjqjFW/psycopg2
Run Code Online (Sandbox Code Playgroud)
我知道这些软件包安装在主系统上,但就像它们不能在venv上工作一样.你们如何解决这个问题?这是一个漫长的一天,我只是不明白问题是什么,特别是因为他们在我的本地系统上工作,他们在我的远程系统上的主要python安装工作,但由于一些疯狂的原因不在venv.有任何想法吗?
这是要求,我认为它对于django而言非常强烈,但那就是什么pip freeze> requirements.txt给了我
Babel==1.3
Django==1.7.1
Fabric==1.10.1
Flask==0.10.1
Flask-Babel==0.9
Flask-Login==0.2.11
Flask-Mail==0.9.1
Flask-OpenID==1.2.4
Flask-SQLAlchemy==2.0
Flask-WTF==0.10.3
Flask-WhooshAlchemy==0.56
Jinja2==2.7.3
MarkupSafe==0.23
PAM==0.4.2
Pillow==2.3.0
Pygments==1.6
Scrapy==0.24.4
Sphinx==1.2.2
Tempita==0.5.2
WTForms==2.0.1
Werkzeug==0.9.6
Whoosh==2.6.0
adium-theme-ubuntu==0.3.4
apt-xapian-index==0.45
argparse==1.2.1
backports.ssl-match-hostname==3.4.0.2
blinker==1.3
boto==2.20.1
bottle==0.12.7
certifi==14.05.14
chardet==2.0.1
colorama==0.2.5
command-not-found==0.3
coverage==3.7.1
cssselect==0.9.1
debtagshw==0.1
decorator==3.4.0
defer==1.0.6
dirspec==13.10
docutils==0.11
duplicity==0.6.23
ecdsa==0.11
flipflop==1.0
guess-language==0.2
guppy==0.1.9
html5lib==0.999
httplib2==0.8
ipython==2.3.1
itsdangerous==0.24
lockfile==0.8
lxml==3.3.3
nose==1.3.4
numpy==1.8.2
oauthlib==0.6.1 …Run Code Online (Sandbox Code Playgroud) 我从来没有进入节点所以我很确定我在这里做了大量的错误,因为我通过谷歌搜索找不到任何信息.
我有一个django网站,我想要一个JS图表库,我选择了chart.js.
我安装并喜欢这些文档,但之后我不确定该怎么做,所以我尽量填写空白并尽可能地遵循他们的指南.这是我的html看起来像....
<script src="/public/node_modules/chart.js/dist/Chart.js"></script>
<canvas id="myChart" width="400" height="400"></canvas>
<script>
var ctx = document.getElementById("myChart");
console.log(ctx);
var options = {}
var data = {
labels: ["January", "February", "March", "April", "May", "June", "July"],
datasets: [
{
label: "My First dataset",
fill: false,
lineTension: 0.1,
backgroundColor: "rgba(75,192,192,0.4)",
borderColor: "rgba(75,192,192,1)",
borderCapStyle: 'butt',
borderDash: [],
borderDashOffset: 0.0,
borderJoinStyle: 'miter',
pointBorderColor: "rgba(75,192,192,1)",
pointBackgroundColor: "#fff",
pointBorderWidth: 1,
pointHoverRadius: 5,
pointHoverBackgroundColor: "rgba(75,192,192,1)",
pointHoverBorderColor: "rgba(220,220,220,1)",
pointHoverBorderWidth: 2,
pointRadius: 1,
pointHitRadius: 10,
data: [65, 59, 80, 81, 56, 55, 40], …Run Code Online (Sandbox Code Playgroud) 我对使用哪个字段感到困惑.我需要的只是一个将保存文件的字段(音频和/或另一个文件)
FileField似乎专门用于上传,我认为它对我所需要的东西有点过分,我也不喜欢每次上传内容时它会如何自动上传并将文件重命名为唯一的文件名(file_FHjgh758.txt) .
我对FilePathField的问题在于它似乎需要一个绝对路径,这显然与开发到生产不同,我通过将其添加到模型来解决这个问题...
import os
class Foo(models.Model):
path = os.path.dirname(os.path.dirname(__file__))
path = os.join(path, 'media')
audio = models.FilePathField(path=path)
Run Code Online (Sandbox Code Playgroud)
我不知道这是否安全或正确,并且在线或在文档中没有很多示例可供借鉴.
为了清楚起见,我只想拥有一个可以指向系统中某个文件(音频或图像)的字段.这样做最好的方法是什么?
我有一个for循环,它使用我编写的sqlite管理器类对数据库进行了许多更改,但我不确定我多久需要提交...
for i in list:
c.execute('UPDATE table x=y WHERE foo=bar')
conn.commit()
c.execute('UPDATE table x=z+y WHERE foo=bar')
conn.commit()
Run Code Online (Sandbox Code Playgroud)
基本上我的问题是我是否必须在那里调用两次提交,或者我是否可以在完成两次更改后调用它一次?
我阅读了文档和这篇文章...... Django - 用户模型的外键
我按照它所说的,我仍然无法让它工作.当我尝试运行迁移时,我在追溯中得到了这个错误...
django.db.utils.ProgrammingError: column "author_id" cannot be cast automatically to type integer
HINT: You might need to specify "USING author_id::integer".
Run Code Online (Sandbox Code Playgroud)
我只是不知道如何解决这个错误.
from django.db import models
from django.contrib.auth.models import User
# Create your models here.
class BlogCategory(models.Model):
'''model for categories'''
title = models.CharField(max_length=30)
description = models.CharField(max_length=100)
class BlogPost(models.Model):
'''a model for a blog post'''
author = models.ForeignKey(User)
date = models.DateField()
title = models.CharField(max_length=100)
post = models.TextField()
Run Code Online (Sandbox Code Playgroud) 我对我的模型进行了一些更改,然后运行了一个
python manage.py makemigrations python manage.py migrate
我得到了这个追溯:
Operations to perform:
Synchronize unmigrated apps: staticfiles, messages
Apply all migrations: sessions, admin, study, auth, quiz, contenttypes, main
Synchronizing apps without migrations:
Creating tables...
Running deferred SQL...
Installing custom SQL...
Running migrations:
Rendering model states... DONE
Applying quiz.0013_auto_20151005_0644...Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 330, 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 393, in run_from_argv
self.execute(*args, **cmd_options)
File …Run Code Online (Sandbox Code Playgroud) Safari不支持.ogg文件,但这并不能阻止wiktionary.org播放ogg文件.我查看了源代码,我无法找到它们是如何播放文件的.
这是他们使用.ogg文件的链接.https://en.wiktionary.org/wiki/File:en-us-the-unstressed.ogg
我在尝试安装依赖于sqlite3的全局包时遇到了构建错误.我不太清楚如何调试这样的节点构建错误,所以任何帮助表示赞赏.从搜索,我可以看出,至少xcode错误不是问题.
我最近更新了OSSierra和Node
OSSierra: 10.13.4
Node: 10.0.0
Yarn: 1.6.0
Run Code Online (Sandbox Code Playgroud)
我这次运行的命令.我在进行其他软件包的全局安装时遇到了同样的错误,所以我认为确切的npm软件包并不重要...
$ yarn global add import-js
Run Code Online (Sandbox Code Playgroud)
错误
yarn global v1.6.0
(node:17489) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning "gatsby > friendly-errors-webpack-plugin@1.7.0" has incorrect peer dependency "webpack@^2.0.0 || ^3.0.0 || ^4.0.0".
warning "gatsby > postcss-cssnext@2.11.0" has unmet peer dependency "caniuse-db@^1.0.30000652".
[4/4] Building fresh packages...
[-/2] ? waiting...
[2/2] …Run Code Online (Sandbox Code Playgroud) 我使用gotests和gorilla mux,我可以对我的http handlefunc处理程序进行单元测试,但它们没有响应正确的http请求方法,因为它们应该在gorilla mux下.我怎么能做一个"实时服务器"版本的测试?
func main() {
router := mux.NewRouter()
router.HandleFunc("/", views.Index).Methods("GET")
}
func Index(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, "INDEX\n")
}
func TestIndex(t *testing.T) {
req, _ := http.NewRequest("GET", "/", nil)
req1, _ := http.NewRequest("POST", "/", nil)
rr := httptest.NewRecorder()
handler := http.HandlerFunc(Index)
type args struct {
w http.ResponseWriter
r *http.Request
}
tests := []struct {
name string
args args
}{
{name: "1: testing get", args: args{w: rr, r: req}},
{name: "2: testing post", args: …Run Code Online (Sandbox Code Playgroud) 如果我想让我的venv尽可能干净,我该如何清理我不需要的东西?让我举一个例子......
说我尝试了一堆新模块......
pip install foo
pip install bar
pip install foobar
pip install foobarfoo
Run Code Online (Sandbox Code Playgroud)
这些模块有自己的一些要求等等.后来我决定要使用哪一个,但后来我的requirements.txt里有一大堆东西,我不记得我需要什么,不知道我做什么什么,取决于什么,等等.
我怎样才能保持清洁和精益?