我在virtualenv中安装了psycopg2 easy_install psycopg2
.我没有看到任何错误,看起来安装很顺利..有一个鸡蛋文件在site-packages目录中为psycopg2创建..
但是当我在解释器中运行import psycopg2时,我得到了以下错误..任何线索?我该如何解决..在virtualenv中安装psycopg2的任何其他方法..
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build\bdist.win32\egg\psycopg2\__init__.py", line 69, in <module>
File "build\bdist.win32\egg\psycopg2\_psycopg.py", line 7, in <module>
File "build\bdist.win32\egg\psycopg2\_psycopg.py", line 6, in __bootstrap__
Run Code Online (Sandbox Code Playgroud)
谢谢.
这是一个类似的问题我如何让setuptools安装一个不在PyPI上的软件包?但不一样.
由于我想使用某些包的分叉版本,setuptools会忽略依赖关系链接(因为它具有相同的版本号).
有没有办法强制使用dependency_links中的链接?或者是更改分叉回购中版本号的唯一方法?
requires = [
...
'pyScss==1.1.3'
...
dependencies = [
'https://github.com/nadavshatz/pyScss/zipball/master#egg=pyScss-1.1.3'
]
Run Code Online (Sandbox Code Playgroud)
更新
奇怪的是,如果这个包是所需列表中唯一尚未安装的包,显然它可以工作.如果有另一个丢失的包,它将从pypi下载它.
I don't have root access and i want to install python from scratch. So I downloaded the python source code and compiled it. Next I wanted to install pip
. But when I ran python get-pip.py
I got this error:
ImportError: cannot import name HTTPSHandler
Not having root access then I couldn't install stuff needed. So I thought maybe I can install pip
with easy_install
so I went and installed setuptools
which has easy_install
. But when I run easy_install …
问题描述:
使用pip,我升级到了最新版本的请求(版本2.7.0,pip show requests
给出了位置/usr/local/lib/python2.7/dist-packages
).但是当我在交互式命令行中import requests
打印requests.__version__
时,我看到的是版本2.2.1.事实证明,Python正在使用预先安装的Ubuntu版本的请求(requests.__file__
是/usr/lib/python2.7/dist-packages/requests/__init__.pyc
- 不是/user/local/lib/...
).
从我的调查来看,这个事实是由于Ubuntu对Python搜索路径的改变(我运行Ubuntu 14.04)引起了Ubuntu Python包的路径(对于我的机器,这种情况发生在usr/local/lib/python2.7/dist-packages/easy-install.pth
).在我的情况下,这会导致使用apt-get
预先与Ubuntu打包的请求版本,而不是我想要使用的pip版本.
我在找什么:
我希望sys.path
在到Ubuntu的Python安装目录的路径之前,全局地将pip的安装目录路径预先添加到Python的搜索路径().由于在我的许多Python脚本中使用了请求(以及许多其他包),我不想手动更改计算机上每个文件的搜索路径.
令人不满意的解决方案1:使用virtualenv
使用virtualenv会对我的机器造成不必要的更改,因为我必须重新安装全局存在的每个包.我只想从Ubuntu的软件包升级到pip的软件包.
不满意的解决方案2:更改easy-install.pth
由于easy-install.pth
每次easy-install
使用都会被覆盖,easy-install.pth
因此如果安装了新软件包,我的更改将被删除.此问题使我很难在我的机器上维护包.
不满意(但我到目前为止最好)解决方案3:添加一个单独的.pth文件
在与easy-install.pth相同的目录中,我添加了一个zzz.pth
内容:
import sys; sys.__plen = len(sys.path)
/usr/lib/python2.7/dist-packages/test_dir
import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:]; p=getattr(sys,'__egginsert',0); sys.path[p:p]=new; sys.__egginsert = p+len(new)
Run Code Online (Sandbox Code Playgroud)
site.py
Python启动时会读取此文件.由于它的文件名easy-install.pth
是以字母数字形式出现的,因此它会在site.py
之后被消耗掉.总之,文件的第一行和最后一行预先添加路径sys.path
(这些行取自easy-install.pth
).
我不喜欢这个解决方案如何依赖于文件名的字母数字排序来正确放置新路径.
PYTHONPATHs来自Ubuntu的路径
Stack Overflow的另一个答案 …
我已经开始认识到ElementTree不会按照我的意愿去做.我已经查看了lxml的文档,看来它将满足我的目的.要获得lxml,我需要获得easy_install.所以我从这里下载了它,然后把它放进去/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
.然后我去了那个文件夹,跑了sh setuptools-0.6c11-py2.6.egg
.
安装成功.然后我很兴奋,因为我认为easy_install的重点是我可以通过easy_install lxml进行安装,并且lxml会神奇地下载,构建和正确安装,为我的导入享受做好准备.所以我跑了easy_install lxml
.我粘贴了下面的结果.我该怎么办?
easy_install lxml
Searching for lxml
Reading http://pypi.python.org/simple/lxml/
Reading http://codespeak.net/lxml
Best match: lxml 2.2.6
Downloading http://codespeak.net/lxml/lxml-2.2.6.tgz
Processing lxml-2.2.6.tgz
Running lxml-2.2.6/setup.py -q bdist_egg --dist-dir /var/folders/49/49N0+g5QFKCm51AbzMtghE+++TI/-Tmp-/easy_install-rxbP6K/lxml-2.2.6/egg-dist-tmp-fjakR0
Building lxml version 2.2.6.
NOTE: Trying to build without Cython, pre-generated 'src/lxml/lxml.etree.c' needs to be available.
Using build configuration of libxslt 1.1.12
Building against libxml2/libxslt in the following directory: /usr/lib
unable to execute gcc-4.0: No such file or directory
error: Setup script exited with …
Run Code Online (Sandbox Code Playgroud) 关注本文后:如何在Windows上安装pip?在我的Windows系统上使用Enthought Canopy 64 Bit系统,由于错误,我无法让pip或easy_install工作:
pip install requests
failed to create process
Run Code Online (Sandbox Code Playgroud)
我尝试重新安装setuptools,运行cmd提示符作为管理员没有任何影响.
我试着按照这个答案的说明但easy_install-2.6
找不到pip
:
>sudo easy_install-2.6 pip
Processing pip
error: Not a recognized archive type: pip
Run Code Online (Sandbox Code Playgroud)
如何为python 2.6安装pip?
在这个帖子中解释了我对pip for 2.6的根需求.
我制作了我的项目,setuptools
我想用它进行测试tox
.我在变量中列出了依赖项并添加到setup()
参数(tests_require
和extras_require
)中.我的项目需要安装tests_require
测试中列出的所有依赖项,但pip install
不安装它们.
我尝试了这个,但它不起作用:
install_command = pip install {opts} {packages}[tests]
Run Code Online (Sandbox Code Playgroud)
如何安装测试依赖项而无需管理多个依赖项列表(即在两者test_requirements.txt
和tests_require
变量中列出所有依赖项)?
我可以下载并安装一封来自PyPI Python模块严格意义上的脚本中,不使用外壳在所有?
我使用非标准的Python环境,Autodesk Maya的Python解释器.这不是"easy_install",并且没有"shell",只有主Maya可执行文件调用的python脚本解释器.将ez_setup.py的内容复制并粘贴到脚本编辑器窗口并正确运行它会将easy_install安装到Maya的目录中,但脚本会错误地将Python解释器记录为"... maya.exe"而不是"... mayapy.exe "此外,使用easy_install需要一个shell.
目标是提供一个Python脚本,例如,将NumPy安装到Maya Python系统中.这可以通过将egg放入site-packages目录来完成,但这需要手动用户干预.最终用户在Maya环境之外必须做的任何事情基本上是不可触及的,尤其是弄乱文件系统.但是通过脚本搞乱文件系统?没关系.
有没有比ez_setup.py更优雅的东西+编辑生成的easy_install ... py的+子进程调用?我觉得这是一个基本功能.我通过pip在线查看程序模块安装的文档...但是需要首先安装pip!
在脚本范围内严格安装模块的最优雅方法是什么?
我想安装sphinx,网站上说要使用:
easy_install -U Sphinx
Run Code Online (Sandbox Code Playgroud)
安装此命令时会发生什么?我也会得到消息来源吗?它将安装在哪里?
easy-install ×10
python ×10
pip ×7
distutils ×2
setuptools ×2
lxml ×1
maya ×1
postgresql ×1
psycopg2 ×1
pythonpath ×1
tox ×1
ubuntu ×1
virtualenv ×1