我使用Macports安装了Pythong2.6,psycopg2和pgAdmin3。我的settings.py是:
DATABASE_ENGINE = 'postgresql_psycopg2' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
DATABASE_NAME = 'mysite' # Or path to database file if using sqlite3.
DATABASE_USER = 'postgres' # Not used with sqlite3.
DATABASE_PASSWORD = '' # Not used with sqlite3.
DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3.
运行python manage.py syncdb时遇到的错误是:
Traceback (most recent call last):
File "manage.py", line 11, in <module>
execute_manager(settings)
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/core/management/__init__.py", line 362, in execute_manager
utility.execute()
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/core/management/__init__.py", line 303, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/core/management/base.py", line 195, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/core/management/base.py", line 221, in execute
self.validate()
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/core/management/base.py", line 249, in validate
num_errors = get_validation_errors(s, app)
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/core/management/validation.py", line 22, in get_validation_errors
from django.db import models, connection
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/db/__init__.py", line 41, in <module>
backend = load_backend(settings.DATABASE_ENGINE)
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/db/__init__.py", line 17, in load_backend
return import_module('.base', 'django.db.backends.%s' % backend_name)
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 22, in <module>
raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: No module named psycopg2
请注意,我是这方面的入门者。我本来是PHP专家,正在为一个小型个人项目试用Python。我需要“打开” Postgres吗?
另外,当我使用sudo python manage.py runserver 8080时,出现此错误:
Validating models...
Unhandled exception in thread started by <function inner_run at 0x1242670>
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/core/management/commands/runserver.py", line 48, in inner_run
self.validate(display_num_errors=True)
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/core/management/base.py", line 249, in validate
num_errors = get_validation_errors(s, app)
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/core/management/validation.py", line 22, in get_validation_errors
from django.db import models, connection
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/db/__init__.py", line 41, in <module>
backend = load_backend(settings.DATABASE_ENGINE)
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/db/__init__.py", line 17, in load_backend
return import_module('.base', 'django.db.backends.%s' % backend_name)
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 22, in <module>
raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: No module named psycopg2
请指导我。任何答复将不胜感激。
谢谢,
你的psycopg2
安装似乎存在问题-Python找不到它。这是Python安装问题,而不是Django问题。
你可以尝试使用Python解释器手动加载它,看看它是否有效:
$ python
>>> import psycopg2
如果出现ImportError异常,则说明安装错误。要获取Python查找模块的所有目录的列表,请使用sys.path:
$ python
>>> import sys
>>> print sys.path
你还可以通过修改sys.path
变量将自定义目录添加到Python的模块搜索路径。在相应import语句之前的某处执行此操作:
import sys
sys.path.append("my-path")
# ...
import psycopg2
Python是一门面向对象的编程语言,它相对于其他语言,更加易学、易读,非常适合快速开发。
错误消息 线程“main”org.openqa.selenium.nosuchelementException:没有这样的元素:找不到元素:{“method”:“XPath”,“Selector”:“.//*[@id='TreeBox1']/div/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td[2]/tab
我是框架新手(刚通过这门课),这是我第一次使用spring boot。 我正在尝试运行一个简单的Junit测试,看看我的CrudRepositories是否真的可以工作。 我不断得到的错误是: 找不到@SpringBootConfiguration,您需要使用@ContextConfiguration或@SpringBootTest(Classes=...)使用您的测试java.lang.Ille
不过,我知道在其他问题中也有人问过这个问题。这件事对我解释得还不够。我对java及其附带的所有东西都是非常陌生的。(我正在使用netbeans) 我读到我需要更新我的Ant?我该怎么做?我查了一下网站,我真的很困惑。 我还看到有人建议添加“-dbuild.compiler=javac1.7”,以避免对其进行更新。我应该把它放在代码的哪个位置呢?谢谢你提前给我时间和建议。真的很感激:)
这是错误消息: 初始化启动层java时出错。lang.module。FindException:无法派生C:\Users\ARVIND\Downloads\poi-bin-5.1的模块描述符。0-20211024\poi-bin-5.1。0\auxiliary\batik-script-1.14。jar是由java引起的。lang.module。InvalidModuleDescriptorExc
问题内容: 我在安装psycopg2时遇到问题。我尝试执行以下操作时收到以下错误pip install psycopg2: 但是问题出在我身上PATH; 它运行没有任何问题: 我尝试将径添加到文件中,并使用从其网站(http://initd.org/psycopg/)下载的源文件进行构建,然后收到以下错误消息! 但实际上是那里!!! 这些错误使我感到困惑。有人可以帮忙吗? 顺便说一下,我sudo所