我正在使用virtualenv,我需要安装"psycopg2".
我做了以下事情:
pip install http://pypi.python.org/packages/source/p/psycopg2/psycopg2-2.4.tar.gz#md5=24f4368e2cfdc1a2b03282ddda814160
Run Code Online (Sandbox Code Playgroud)
我有以下消息:
Downloading/unpacking http://pypi.python.org/packages/source/p/psycopg2/psycopg2
-2.4.tar.gz#md5=24f4368e2cfdc1a2b03282ddda814160
Downloading psycopg2-2.4.tar.gz (607Kb): 607Kb downloaded
Running setup.py egg_info for package from http://pypi.python.org/packages/sou
rce/p/psycopg2/psycopg2-2.4.tar.gz#md5=24f4368e2cfdc1a2b03282ddda814160
Error: pg_config executable not found.
Please add the directory containing pg_config to the PATH
or specify the full executable path with the option:
python setup.py build_ext --pg-config /path/to/pg_config build ...
or with the pg_config option in 'setup.cfg'.
Complete output from command python setup.py egg_info:
running egg_info
creating pip-egg-info\psycopg2.egg-info
writing pip-egg-info\psycopg2.egg-info\PKG-INFO
writing top-level names to pip-egg-info\psycopg2.egg-info\top_level.txt
writing …Run Code Online (Sandbox Code Playgroud) 我需要创建一个中央Git存储库,但我有点困惑......
我创建了一个裸存储库(在我的git服务器,机器2中):
$ mkdir test_repo
$ git --bare init
Run Code Online (Sandbox Code Playgroud)
现在我需要将文件从我的本地存储库(机器1)推送到裸存储库(机器2).我可以通过SSH访问机器2.问题是,我认为我不理解裸存储库的概念......
将我的代码存储在裸存储库中的正确方法是什么?如何将更改从本地存储库推送到裸存储库?
拥有中央存储库以获得裸存储库的正确方法是什么?
我对这个问题有点困惑.请给我一个线索.
我在安装了Python 2.4的Web托管中有一个共享帐户,但我的代码与2.4不兼容.是否可以直接将Python 2.6安装到Virtualenv?
注意:我没有权限在共享服务器中安装它.
我已经通过重命名其文件夹,导入及其所有引用(模板/索引)来更改Django中应用程序的名称.但是现在我尝试运行时遇到了这个错误python manage.py runserver
Error: Could not import settings 'nameofmynewapp.settings' (Is it on sys.path?): No module named settings
Run Code Online (Sandbox Code Playgroud)
如何调试并解决此错误?有线索吗?
我是Python和Django的新手.
我正在使用PostgreSQL数据库引擎后端配置Django项目,但我在每个数据库操作上都遇到错误,例如当我运行时manage.py syncdb,我得到:
C:\xampp\htdocs\djangodir>python manage.py syncdb
Traceback (most recent call last):
File "manage.py", line 11, in <module>
execute_manager(settings)
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line
438, in execute_manager
utility.execute()
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line
379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line
261, in fetch_command
klass = load_command_class(app_name, subcommand)
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line
67, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "C:\Python27\lib\site-packages\django\utils\importlib.py", line 35, in im
port_module
__import__(name)
File "C:\Python27\lib\site-packages\django\core\management\commands\syncdb.py"
, line 7, in <module>
from django.core.management.sql import custom_sql_for_model, emit_post_sync_
signal
File "C:\Python27\lib\site-packages\django\core\management\sql.py", line …Run Code Online (Sandbox Code Playgroud) 我是Python的新手,我正在开始一个迷你项目,但我对如何在"Python方式"中组织文件夹有一些疑问.
我PyDev在我的开发环境中使用,当我创建一个新项目时,会创建一个名为的文件夹src
+ src
Run Code Online (Sandbox Code Playgroud)
现在,在PyDev,我可以创造Pydev Module和PyDev Package
我需要以下列方式组织我的项目:
+ Indicators
- Moving_averages.py
- Stochastics.py
+ Strategies
- Moving_averages_cross.py
- example.py
Run Code Online (Sandbox Code Playgroud)
如何根据模块和包进行组织?Modules and Packages是什么意思?
最好的祝福,
我的一个模型中有问题.我正在上传一个图片,我想存储id(数据库表中的pk),但我需要知道Django可以访问哪个点 self.id.
models.py
class BicycleAdItemKind(MPTTModel):
def url(self, filename):
pdb.set_trace()
url = "MultimediaData/HelpAdImages/ItemKind/%s/%s" % (self.id, filename)
return url
def item_kind_image(self):
return '<img align="middle" src="/media/%s" height="60px" />' % self.image
item_kind_image.allow_tags = True
# Bicicleta completa, Componentes para bicicleta, Acessorios para ciclista
n_item_kind = models.CharField(max_length=50)
parent = TreeForeignKey('self', null=True,
blank=True, related_name='children')
description = models.TextField(null=True, blank=True)
image = models.ImageField(upload_to=url, null=True, blank=True)
date_inserted = models.DateTimeField(auto_now_add=True)
date_last_update = models.DateTimeField(auto_now=True)
def __unicode__(self):
return self.n_item_kind
class MPTTMeta:
order_insertion_by = ['n_item_kind']
Run Code Online (Sandbox Code Playgroud)
问题出在url()方法上; 我只能self.id在更新对象时得到,我self.id …
我需要使用HTML5 pattern属性仅允许<input type="file">元素中的JPG,GIF和PNG文件.
我目前有这种模式,但它不起作用:
<input type="file" class="input-file" id="tbinstUploadFile0" name="tbinstUploadFile0" placeholder="Please insert an image file..." pattern="([^\s]+(\.(?i)(jpg|png|gif|bmp))$)">
Run Code Online (Sandbox Code Playgroud)
这个正则表达式模式与HTML5不兼容?如何测试有效的HTML5正则表达式模式?
最好的祝福,
我正在使用Express与Socket.io,但我无法弄清楚如何在Express路线中使用SocKet.io.
我最终在"app.js"中这样做
...
...
// development only
if ('development' == app.get('env')) {
app.use(express.errorHandler());
}
var server = http.createServer(app);
var io = require("socket.io").listen(server);
app.get('/', routes.index);
app.get('/users', user.list);
app.post('/cmp', function(request, response) {
var client = new pg.Client("pg://user:pass@127.0.0.1/db_name");
client.connect(function(err) {
// Get the product_id and bid
var product_id = request.body.product_id;
var bid = request.body.bid.split('b')[1];
// If not get the connection
if(err) {
return console.error('could not connect to postgres', err);
}
client.query('select 1 from product_bid where product_id = $1 and number_bid = $2', [product_id, …Run Code Online (Sandbox Code Playgroud) 假设我有以下字符串:
http://www.domain.com/?s=some&two=20
Run Code Online (Sandbox Code Playgroud)
我怎样才能取消&包括以下内容&并拥有此字符串:
http://www.domain.com/?s=some
Run Code Online (Sandbox Code Playgroud) python ×6
django ×3
psycopg2 ×2
virtualenv ×2
django-mptt ×1
express ×1
git ×1
html5 ×1
node.js ×1
pip ×1
postgresql ×1
pydev ×1
regex ×1
socket.io ×1
string ×1