Pip install hashlib error

I am trying to install the hashlib library for Python 3.6.0. Using pip3: pip3 install hashlib I get: Collecting hashlib Downloading hashlib-20081119.zip (42kB) 100% |████████████████████████...

I am trying to install the hashlib library for Python 3.6.0. Using pip3:

pip3 install hashlib

I get:

Collecting hashlib
  Downloading hashlib-20081119.zip (42kB)
  100% |████████████████████████████████| 51kB 1.6MB/s
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/setuptools/__init__.py", line 10, in <module>
        from setuptools.extern.six.moves import filter, filterfalse, map
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/setuptools/extern/__init__.py", line 1, in <module>
        from pkg_resources.extern import VendorImporter
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pkg_resources/__init__.py", line 36, in <module>
        import email.parser
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/email/parser.py", line 12, in <module>
        from email.feedparser import FeedParser, BytesFeedParser
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/email/feedparser.py", line 27, in <module>
        from email._policybase import compat32
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/email/_policybase.py", line 9, in <module>
        from email.utils import _has_surrogates
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/email/utils.py", line 28, in <module>
        import random
      File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/random.py", line 46, in <module>
        from hashlib import sha512 as _sha512
      File "/private/var/folders/3m/q2pmrqbd2l9154yp_9ww5rjm0000gn/T/pip-build-1upkmzey/hashlib/hashlib.py", line 80
        raise ValueError, "unsupported hash type"
                        ^
    SyntaxError: invalid syntax

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/3m/q2pmrqbd2l9154yp_9ww5rjm0000gn/T/pip-build-1upkmzey/hashlib/

Any idea on how to fix this? I am currently on macOS Sierra 10.12.6, using pip3 9.0.1 and python 3.6.

Содержание

  1. Я не могу установить hashlib вручную
  2. 2 ответа
  3. hashlib и hmac в python3
  4. pip doesn’t work in FIPS mode #4049
  5. Comments
  6. Description:
  7. hashlib 20081119
  8. Навигация
  9. Ссылки проекта
  10. Статистика
  11. Метаданные
  12. Сопровождающие
  13. Классификаторы
  14. Описание проекта
  15. Подробности проекта
  16. Ссылки проекта
  17. Статистика
  18. Метаданные
  19. How to install a Python Module?
  20. Installing Python modules in Windows
  21. Using PIP in Python
  22. Example
  23. Output
  24. Example
  25. Output
  26. Checking PIP version
  27. Using Conda in Python
  28. Searching Packages
  29. Output
  30. Installing Packages
  31. Output

Я не могу установить hashlib вручную

Я не уверен, почему, но когда я устанавливаю hashlib, это дает мне ошибку. Я уже пробовал множество потенциальных решений, и я был бы признателен за любую помощь.

$ pip install —user hashlib Collecting hashlib Using cached https://files.pythonhosted.org/packages/74/bb/9003d081345e9f0451884146e9ea2cff6e4cc4deac9ffd4a9ee98b318a49/hashlib-20081119.zip Complete output from command python setup.py egg_info: Traceback (most recent call last): File » «, line 1, in File «/home/tania/anaconda3/lib/python3.6/site-packages/setuptools/__init__.py», line 12, in import setuptools.version File «/home/tania/anaconda3/lib/python3.6/site-packages/setuptools/version.py», line 1, in import pkg_resources File «/home/tania/anaconda3/lib/python3.6/site-packages/pkg_resources/__init__.py», line 36, in import email.parser File «/home/tania/anaconda3/lib/python3.6/email/parser.py», line 12, in from email.feedparser import FeedParser, BytesFeedParser File «/home/tania/anaconda3/lib/python3.6/email/feedparser.py», line 27, in from email._policybase import compat32 File «/home/tania/anaconda3/lib/python3.6/email/_policybase.py», line 9, in from email.utils import _has_surrogates File «/home/tania/anaconda3/lib/python3.6/email/utils.py», line 28, in import random File «/home/tania/anaconda3/lib/python3.6/random.py», line 46, in from hashlib import sha512 as _sha512 File «/tmp/pip-install-vm0l089t/hashlib/hashlib.py», line 80 raise ValueError, «unsupported hash type» ^ SyntaxError: invalid syntax Command «python setup.py egg_info» failed with error code 1 in /tmp/pip-install-vm0l089t/hashlib/

2 ответа

Note1: pip обычно является командой python2.

Примечание2: присутствует современная «хэшлиб» по умолчанию:

$ locate hashlib.py /snap/core/4486/usr/lib/python3.5/hashlib.py /snap/core/4571/usr/lib/python3.5/hashlib.py /snap/pulsemixer/23/usr/lib/python3.5/hashlib.py /snap/pulsemixer/8/usr/lib/python3.5/hashlib.py /snap/software-boutique/31/usr/lib/python3.5/hashlib.py /snap/ubuntu-mate-welcome/169/usr/lib/python3.5/hashlib.py /usr/lib/python2.7/hashlib.py /usr/lib/python2.7/hashlib.pyc /usr/lib/python3.6/hashlib.py

Hashlib-2008: Как и имя говорит → год 2008: файлы, которые старые часто терпят неудачу с gcc-7.

Вручную: Получить hashlib-20081119.zip https : //files.pythonhosted.org/packages/74/bb/9003d081345e9f0451884146e9ea2cff6e4cc4deac9ffd4a9ee98b318a49/hashlib-20081119.zip

Пример с Ubuntu 18.04 и python2 (сбой с python3):

sudo apt install g++ g++-5 unzip hashlib-20081119.zip cd hashlib-20081119/ export CC=gcc-5 && python setup.py build && sudo python setup.py install . . Writing /usr/local/lib/python2.7/dist-packages/hashlib-20081119.egg-info

Note1: pip обычно является командой python2.

Примечание2: присутствует современная «хэшлиб» по умолчанию:

$ locate hashlib.py /snap/core/4486/usr/lib/python3.5/hashlib.py /snap/core/4571/usr/lib/python3.5/hashlib.py /snap/pulsemixer/23/usr/lib/python3.5/hashlib.py /snap/pulsemixer/8/usr/lib/python3.5/hashlib.py /snap/software-boutique/31/usr/lib/python3.5/hashlib.py /snap/ubuntu-mate-welcome/169/usr/lib/python3.5/hashlib.py /usr/lib/python2.7/hashlib.py /usr/lib/python2.7/hashlib.pyc /usr/lib/python3.6/hashlib.py

Hashlib-2008: Как и имя говорит → год 2008: файлы, которые старые часто терпят неудачу с gcc-7.

Вручную: Получить hashlib-20081119.zip https : //files.pythonhosted.org/packages/74/bb/9003d081345e9f0451884146e9ea2cff6e4cc4deac9ffd4a9ee98b318a49/hashlib-20081119.zip

Пример с Ubuntu 18.04 и python2 (сбой с python3):

Источник

hashlib и hmac в python3

собственно пишу софтину на python3 + pyqt5. Потребовалось заюзать hmac, ставлю через pip3, выдает:

openssl в арче стоит, pyopenssl так же стоит через pip3

Разве это не встроенная либа?

Серьёзно? Модуль 2010 года? В описании которого написано: «This is a stand alone packaging of the hashlib compatible hmac library included with Python 2.5 so that it can be used together with the hashlib backport on older versions of Python (tested on 2.4). Not needed with Python 2.5 or later»?

Этот модуль уже есть в Python 2.5 и более поздних версиях. Есть он и в Python 3: https://docs.python.org/3/library/hmac.html

да, с питоном дело в том что был плохо знаком, пришлось за день на нем запилить одну прилагу, получилось, теперь понял почему питонисты все ругают python3, вернулся на python2 ))))

теперь понял почему питонисты все ругают python3

эээ, а я не понял

имхо скажу так, я заюзал в работе python наверное впервые (не считая фиксов мелких), сразу взял python3 + pyqt5, дофигища мелких изменений, которые вообще не знаю зачем были сделаны в python 3, не удобно доки гуглить к примеру. Как мне показалось он менее удобен чем python 2. как то так. И кстате например с тем же hmac, он вообще по другому практически работает, в плане создания хеша самого.

Источник

pip doesn’t work in FIPS mode #4049

Pip version:
pip 7.1.0 from /usr/lib/python2.6/site-packages (python 2.6)

Python version:
Python 2.6.6

Operating System:
redhat-release-server-6Server-6.8.0.5.el6.x86_64

Description:

I can’t install any package by pip on systems in FIPS mode (Federal Information Processing Standard ). Problem is using hashlib and md5.

I received following traceback.

The text was updated successfully, but these errors were encountered:

both pip and your python are massively outdated,
please check with an upstream version and note that the fips modification looks like something that should be handled by redhat’s pip package, not pip upstream itself

Hi, thank you for your answer. I tried run new pip on CentOS7 and the result is identical.

pip 8.1.2 from /usr/lib/python2.7/site-packages (python 2.7) — Python 2.7.5

Unknown hash name: md5

Current PyPI relies on MD5 hashes which is not FIPS compatible. You can switch over to using https://pypi.org/simple/ which uses sha256 hashes and thus should be FIPS compatible.

Sorry, @dstufft , how can you switch over to using https://pypi.org/simple/ ? Is it pip configuration? Can it be done from the command-line? Thanks

Nevermind. I figured it out: By specifiying the -i option. Thanks

@Pajinek i believe its a RHEL Issue that the downstream version of pip uses a index that will break it in fips mode, i believe it can be elevated by configuring the default index as @dstufft mentioned

Wanted to mention, MD5 is not secure if pip is using this for integrity verification of packages. Its prone to collision attacks and apps should move to using sha2 or gpg (if they can — although I understand migration can be a challenge for already computed hashes).

That is why FIPS is blocking MD5, as its a security hazard.

I’m having the same problem. Can someone give an example using the -I option with https://pypi.org/simple please?

@gshennessy , I think you can just run something like this:

pip install -i https://pypi.org/simple/ requests , replacing requests with your desired package.

The problem still seems present, although it displays differently.

]# pip install -i https://pypi.org/simple/ pyfits
Collecting pyfits
Downloading https://files.pythonhosted.org/packages/45/98/d6d25932e6a82fa8456d38ab307bfb8945a1e1dd4e896730555e3b61cfc5/pyfits-3.4.tar.gz (1.7MB)
100% |████████████████████████████████| 1.7MB 220kB/s
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File «», line 1, in
File «/tmp/pip-build-4YavCt/pyfits/setup.py», line 14, in
zip_safe=False
File «/usr/lib64/python2.7/distutils/core.py», line 112, in setup
_setup_distribution = dist = klass(attrs)
File «/usr/lib/python2.7/site-packages/setuptools/dist.py», line 265, in init
self.fetch_build_eggs(attrs.pop(‘setup_requires’))
File «/usr/lib/python2.7/site-packages/setuptools/dist.py», line 289, in fetch_build_eggs
parse_requirements(requires), installer=self.fetch_build_egg
File «/usr/lib/python2.7/site-packages/pkg_resources.py», line 618, in resolve
dist = best[req.key] = env.best_match(req, self, installer)
File «/usr/lib/python2.7/site-packages/pkg_resources.py», line 862, in best_match
return self.obtain(req, installer) # try and download/install
File «/usr/lib/python2.7/site-packages/pkg_resources.py», line 874, in obtain
return installer(requirement)
File «/usr/lib/python2.7/site-packages/setuptools/dist.py», line 339, in fetch_build_egg
return cmd.easy_install(req)
File «/usr/lib/python2.7/site-packages/setuptools/command/easy_install.py», line 611, in easy_install
self.local_index
File «/usr/lib/python2.7/site-packages/setuptools/package_index.py», line 598, in fetch_distribution
return dist.clone(location=self.download(dist.location, tmpdir))
File «/usr/lib/python2.7/site-packages/setuptools/package_index.py», line 515, in download
found = self._download_url(scheme.group(1), spec, tmpdir)
File «/usr/lib/python2.7/site-packages/setuptools/package_index.py», line 762, in _download_url
return self._attempt_download(url, filename)
File «/usr/lib/python2.7/site-packages/setuptools/package_index.py», line 768, in _attempt_download
headers = self._download_to(url, filename)
File «/usr/lib/python2.7/site-packages/setuptools/package_index.py», line 661, in _download_to
checker = HashChecker.from_url(url)
File «/usr/lib/python2.7/site-packages/setuptools/package_index.py», line 247, in from_url
return cls(**match.groupdict())
File «/usr/lib/python2.7/site-packages/setuptools/package_index.py», line 235, in init
self.hash = hashlib.new(hash_name)
File «/usr/lib64/python2.7/hashlib.py», line 111, in __hash_new
return _hashlib.new(name, string, usedforsecurity)
ValueError: error:060800A3:digital envelope routines:EVP_DigestInit_ex:disabled for fips

Command «python setup.py egg_info» failed with error code 1 in /tmp/pip-build-4YavCt/pyfits/
[root@lin2v56ad-03

This is really an issue with PyPI not with pip, and since Warehouse solves this already I’m going to just close this issue. If you want regular PyPI to drop the use of MD5 prior to the switch to Warehouse, please start a thread on distutils-sig.

Источник

hashlib 20081119

pip install hashlib Скопировать инструкции PIP

Выпущен: 3 июл. 2009 г.

Secure hash and message digest algorithm library

Навигация

Ссылки проекта

Статистика

Метаданные

Лицензия: Python Software Foundation License

Сопровождающий: Gregory P. Smith

Метки hashlib, md5, sha1, sha, sha256, sha512, hash, digest, openssl

Сопровождающие

Классификаторы

  • Development Status
    • 5 — Production/Stable
  • Intended Audience
    • Developers
  • License
    • OSI Approved :: Python Software Foundation License
  • Programming Language
    • Python
  • Topic
    • Communications
    • Security :: Cryptography

Описание проекта

Provides the SHA-224, SHA-256, SHA-384, SHA-512 hash algorithms in addition to platform optimized versions of MD5 and SHA1. If OpenSSL is present all of its hash algorithms are provided.

This is a stand alone packaging of the hashlib library included with Python 2.5 so that it can be used on older versions of Python (tested on 2.3 and 2.4).

Подробности проекта

Ссылки проекта

Статистика

Метаданные

Лицензия: Python Software Foundation License

Сопровождающий: Gregory P. Smith

Метки hashlib, md5, sha1, sha, sha256, sha512, hash, digest, openssl

Источник

How to install a Python Module?

A file containing Python definitions and statements is referred to as a module. A module is a file that contains Python code; an “Program.py” file would be a module with the name “Program”. We utilise modules to divide complicated programs into smaller, more manageable pieces. Code reuse is also possible with modules. Instead of copying their definitions into several programs, we can define our most frequently used functions in a module and import it.

Installing Python modules in Windows

The Python package manager (pip) allows for the installation of modules and packages. Open a terminal and use the pip command to install a module across the entire system.

Using PIP in Python

PIP is a package manager for Python modules or packages. PIP comes inbuilt in Python versions 3.4 and beyond.

Example

The newest version of a module and any dependencies will be installed using the following command from the Python Package Index −

Output

Following is the output after installing any modules −

Note − That will automatically install a Python module. Typically, instead of installing modules on your entire computer, you utilise a virtual environment, or venv.

You need pip set up in order for this to function. The installation procedure is platform-dependent.

Python 3.4 or newer is required because pip is included in that version.

Example

Run the following command if pip is not accessible and you are using Python 3.4 or later −

Output

Following is an output of the above code

Checking PIP version

Locate the script directory for Python on your command line, and then type the following to verify your version −

The output comes as follows −

You can use pip to install python packages. For example, to install the latest version of «SomeProject» −

To install a specific version use the following command

To install greater than or equal to one version and less than another use the following command −

Using Conda in Python

Running on Windows, macOS, Linux, and z/OS, Conda is an open source package management and environment management system. Conda installs, runs, and updates packages as well as the dependencies on them quickly.

On your own computer, Conda makes creating, saving, loading, and switching between environments simple. It was designed to package and distribute Python programs, but it can do the same for any language’s software.

You can search and install packages with the help of Conda as a package management. Conda is an environment manager, so you do not need to switch to another one if you require a package that needs a different version of Python.

Searching Packages

For the later steps, use an Anaconda Prompt or the terminal to check whether a certain package, like “hiredis”, is accessible for installation −

Output

Following runs as an output for the above command −

Installing Packages

Use an Anaconda Prompt or the terminal to install a certain package, like “hiredis” −

Output

Following runs as an output for the above command −

Источник

Environment

  • pip version: pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.5)
  • Python version: Python 3.5.3
  • OS: Linux raspberrypi 4.14.98-v7+ #1200 SMP Tue Feb 12 20:27:48 GMT 2019 armv7l GNU/Linux

Description

When I try to use pip to install hashlib, an error occurs.

Expected behavior

I was expecting pip to install hashlib successfully.

How to Reproduce

  1. Try to install hashlib using one of the following 2 commands:
    python3 -m pip install --upgrade hashlib
    pip3 install hashlib

Output

pi@raspberrypi:~$ python3 -m pip install --upgrade hashlib
Collecting hashlib
  Downloading https://files.pythonhosted.org/packages/74/bb/9003d081345e9f0451884146e9ea2cff6e4cc4deac9ffd4a9ee98b318a49/hashlib-20081119.zip (42kB)
    100% |████████████████████████████████| 51kB 906kB/s
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 10, in <module>
        from setuptools.extern.six.moves import filter, map
      File "/usr/lib/python3/dist-packages/setuptools/extern/__init__.py", line 1, in <module>
        from pkg_resources.extern import VendorImporter
      File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 36, in <module>
        import email.parser
      File "/usr/lib/python3.5/email/parser.py", line 12, in <module>
        from email.feedparser import FeedParser, BytesFeedParser
      File "/usr/lib/python3.5/email/feedparser.py", line 27, in <module>
        from email import message
      File "/usr/lib/python3.5/email/message.py", line 16, in <module>
        from email import utils
      File "/usr/lib/python3.5/email/utils.py", line 28, in <module>
        import random
      File "/usr/lib/python3.5/random.py", line 45, in <module>
        from hashlib import sha512 as _sha512
      File "/tmp/pip-build-kwn076c_/hashlib/hashlib.py", line 80
        raise ValueError, "unsupported hash type"
                        ^
    SyntaxError: invalid syntax

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-kwn076c_/hashlib/

Comments
I have had great success installing other modules — it is a problem specifically with this module. Is there a bug tracker specifically for the hashlib module?

Понравилась статья? Поделить с друзьями:
  • Php fatal error allowed memory size of 134217728 bytes exhausted tried to allocate 36864 bytes
  • Pioneer deh 5600bt ошибка 10
  • Php curl error 60 ssl certificate problem unable to get local issuer certificate
  • Pickle load error
  • Php curl 500 error