pip说这个模块已经安装了python(pip says that module has already been installed while python)
现在我的当前设置的一些背景:我在Centos 6上运行Python3.3。我目前正在使用Flask运行的Web应用程序,它运行在Apache 2.2.15上,模式为WSGI 4.5.3和virtualenv 15.0.2。
pip --version pip 8.1.2 from /usr/local/bin/lib/python3.3/site-packages (python 3.3)
我用pip安装了pysvn,当我运行
pip show pysvn
说
Location: /usr/local/bin/lib/python3.3/site-packages
递归设置为
/usr/local/bin/lib/python3.3/site-packages
755
权限。 我将--system-site-packages
参数传递给virtualenv以使用全局站点包。即使我尝试从python解释器导入包它也不起作用。 因此,它不是特定于我的virtualenv设置,而是一个全局问题。
我必须提一下,使用pip安装的其他软件包工作完全正常(即烧瓶)。
在向你们展示之前,我已经筋疲力尽了所有其他途径。 任何建议都会受到高度赞赏,因为我没有想法。
LE
我确实设法安装它。 我不完全确定为什么以及如何,但我认为是兼容性问题。
首先,我已经卸载了svn 1.6+并安装了1.8.16版本,而这似乎是针对最新的两个版本进行测试的。
其次,我已经卸载了麻烦的pysvn实例并安装了pysvn-1.8.0工作台“sudo / var / www / FlaskApp / FlaskApp / flask / bin / pip install pysvn-1.8.0.tar.gz”。 在这种情况下,我已经安装了我的本地环境。 pysvn的1.9.0版本无效。
LLE
误报,仍然不起作用。 我将通过命令行从我的脚本与svn进行交互。
LLLE安装svn 1.8.16和svn-devel以及自述文件中描述的其余依赖项之后,我已经设法从源代码中成功安装它,不再使用说明。
谢谢你的帮助巴里。
Now a bit of background of my current setup: I have Python3.3 running on Centos 6. I'm currently working on a web application using Flask that runs on Apache 2.2.15 with mode WSGI 4.5.3 and virtualenv 15.0.2.
pip --version pip 8.1.2 from /usr/local/bin/lib/python3.3/site-packages (python 3.3)
I have installed pysvn with pip and when I run
pip show pysvn
says
Location: /usr/local/bin/lib/python3.3/site-packages
755
permissions recursively set to/usr/local/bin/lib/python3.3/site-packages
. And I passed--system-site-packages
argument to virtualenv to use the global site packages.Even when I try to import the package from python interpreter it does not work. So it is not specific to my virtualenv setup but rather a global problem.
I must mention that other packages installed with pip work perfectly fine (i.e. flask).
I've exhausted all other avenues before coming forward to you guys. Any suggestion would be highly appreciated as I ran out of ideas.
L.E.
I did manage to install it in the end. I'm not completly sure yet why and how but I presume is was compatibility issue.
First of all I have uninstalled svn 1.6+ and installed version 1.8.16 instead which seems to be tested against the latest two versions.
Second, I have uninstalled the troublesome pysvn instance and installed pysvn-1.8.0 workbench "sudo /var/www/FlaskApp/FlaskApp/flask/bin/pip install pysvn-1.8.0.tar.gz". In this case I have installed it my local environment. The 1.9.0 version of pysvn did not work.
L.L.E.
False positive, still doesn't work. I'm going to interact with svn via command line from my script.
L.L.L.E. After installing svn 1.8.16 and svn-devel along with the rest of dependencies described in the readme file I have managed to successfully install it from the source fallowing the instructions.
Thanks for your help Barry.
原文:https://stackoverflow.com/questions/39062764
最满意答案
这不仅仅是hashlib - Python 2通过尝试将其编码为ascii来处理许多地方的Unicode。 这是对Python 3做出的重大改变之一。
在Python 3中,字符串是unicode,它们的行为与您的预期相同:没有自动转换为字节,如果要使用字节(例如,用于MD5散列),则必须对它们进行编码。 我相信有使用
sys.setdefaultencoding
黑客可以在Python 2中启用此行为,但我建议不要在生产中使用它们,因为它们会影响在该Python实例中运行的任何代码。It's not just hashlib - Python 2 handles Unicode in a number of places by trying to encode it as ascii. This was one of the big changes made for Python 3.
In Python 3, strings are unicode, and they behave as you expect: there's no automatic conversion to bytes, and you have to encode them if you want to use bytes (e.g. for MD5 hashing). I believe there are hacks using
sys.setdefaultencoding
that enable this behaviour in Python 2, but I'd advise against using them in production, because they'll affect any code running in that Python instance.
相关问答
更多-
MVC强类型视图数据(MVC strongly typed view data)[2022-04-30]
在asp.net mvc中你传递模型来查看如下: public ActionResult Base() { return View(new DerviedOne()); } 这是您的模型定义: public class BaseModel { public int Id { get; set; } } public class DerviedOne : BaseModel { ... -
Python输出是摘要的原始字节。 R 摘要函数也支持raw参数。 digest("asdf", algo="sha256", serialize=FALSE, raw=TRUE) The Python output is the raw bytes of the digest. The R digest function also supports this with the raw argument. digest("asdf", algo="sha256", serialize=FALSE, raw ...
-
如果你想要这个更简单的方法来概括它,所以你可以从中获得更多的使用,而不是将其定制到特定的东西。 那么问题不是“我应该为这个具体的事情做一个全新的班级吗?” 但“我应该用我的公用事业吗?”; 后者总是是的。 实用程序总是有帮助的。 所以做一些像: template
void check_range(const T& pX, const T& pMin, const T& pMax) { if (pX < pMin || pX > pMax) throw std ... -
Python是强类型吗?(Is Python strongly typed?)[2023-07-20]
Python是强大的动态类型。 强打字意味着值的类型不会突然改变。 一个只包含数字的字符串并不奇怪地成为一个数字,正如在Perl中可能发生的那样。 每种类型的更改都需要明确的转换。 动态输入意味着运行时对象(值)具有类型,而不是静态类型,其中变量具有类型。 至于你的例子 bob = 1 bob = "bob" 这是因为变量没有类型; 它可以命名任何对象。 在bob=1 ,你会发现type(bob)返回int ,但是在bob="bob" ,它返回str 。 (请注意, type是一个常规函数,因此它将评估其 ... -
实际上,_sha模块由shamodule.c提供,_md5由md5module.c和md5.c提供,并且两者都将仅在您的Python未使用OpenSSL进行默认编译时才会生成。 您可以在Python Source tarball中的setup.py中找到详细信息。 if COMPILED_WITH_PYDEBUG or not have_usable_openssl: # The _sha module implements the SHA1 hash algorithm. ...
-
持久的hashlib状态(Persisting hashlib state)[2022-03-26]
您可以使用ctypes这样做, C中不需要帮助应用程序: - rehash.py #! /usr/bin/env python ''' A resumable implementation of SHA-256 using ctypes with the OpenSSL crypto library Written by PM 2Ring 2014.11.13 ''' from ctypes import * SHA_LBLOCK = 16 SHA256_DIGEST_LENGTH = 32 ... -
这不仅仅是hashlib - Python 2通过尝试将其编码为ascii来处理许多地方的Unicode。 这是对Python 3做出的重大改变之一。 在Python 3中,字符串是unicode,它们的行为与您的预期相同:没有自动转换为字节,如果要使用字节(例如,用于MD5散列),则必须对它们进行编码。 我相信有使用sys.setdefaultencoding黑客可以在Python 2中启用此行为,但我建议不要在生产中使用它们,因为它们会影响在该Python实例中运行的任何代码。 It's not jus ...
-
以下是您在发布之前应该尝试的内容: Python 2.7: >>> import md5 >>> password = 'fred' >>> nonce = '12345' >>> md5.new(nonce + ':'+ md5.new(password).hexdigest()).hexdigest() '496a1ca20abf5b0b12ab7f9891d04201' Python 2.7和Python 3.6: >>> import hashlib >>> password = 'fred' > ...
-
Hashlib MemoryError在Python 3.5中,但不在2.7中(Hashlib MemoryError in Python 3.5 but not in 2.7)[2022-09-01]
在Python 3中,您需要设置b''而不是''作为iter调用的iter值: iter(functools.partial(f.read, 256), b'') 你也不应该使用列表理解来解决这样的副作用,但是如果你正在移植现有的代码,那么最好现在就离开它。 On Python 3, you need to set b'' instead of '' as the sentinel value for the iter call: iter(functools.partial(f.read, 256), ... -
Python递归Hashlib(Python Recursive Hashlib)[2021-11-26]
import sys from os import listdir from os.path import isfile, join import hashlib path = sys.argv[1] #PATH OF THE FILES, ex: /etc/shadow, /bin/*, etc. files = [ f for f in listdir(path) if isfile(join(path,f)) ] my_files = {} for fil in files: with ope ...