I installed a python package that I need, and tried to import it, but there's a line of code in the package:
from hashlib import blake2s
which returned the error:
ImportError: cannot import name 'blake2s'
After a bit of reading, I found that the hashlib module in Python 3.6+ has blake2s, but I'm using Python 3.5.6. Updating my Python version would solve this problem, but I don't have admin access on this system. So I'm stuck on Python 3.5.6.
Is there a way to get blake2s working in Python 3.5?
edit: I'm wondering if this can be used somehow...
https://github.com/dchest/pyblake2
Answering my own question...
I installed the pyblake2 package (linked in my edit above), then went inside the package I was trying to install and modified the import line.
I changed
from hashlib import blake2s
to
from pyblake2 import blake2s
and then reinstalled the package with that modified line.
It worked! The package is working in Python 3.5 even though Python 3.5 hashlib does not have blake2s.
Related
Nube at Python but application I want to use is written in it and I am having trouble getting this application to work.
I have been searching for answers but perhaps don't know enough to ask the right questions.
I am running windows 10 (new to it also). I have installed Python 3.10.1 from the Windows store. It is in the path statement and does execute from cmd prompt.
As my application uses YAML I have also installed PyYaml,
I have no idea if it installed correctly, where it is installed and it is not in the PATH.
My application called wireviz.py is launched from its source folder by typing wireviz -V. It fails at line 10 with ModuleNotFoundError: No module named 'yaml'.
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3
4 import argparse
5 import os
6 from pathlib import Path
7 import sys
8 from typing import Any, Tuple
9
10 import yaml
I know much more may be needed, but frankly I don't know
what and maybe even how to get it.
The error message indicates that PyYAML is not installed; since PyYAML is registered under the Python Package Index (PyPI) as yaml, you should install it using pip (the Python package installer). The command might look like this:
pip install yaml
There are many more nuances to learn about package installation, but for the time being this should get you up and running.
Problem solved thanks to Austin advise.
Because of it I did some research on Python Installer to get a better feel for the process.
Found my stuff was installed all over the place.
Found a pip package for my application so I deleted everything including Python and did a fresh install of Python and the "Graphviz" applications.
Then installed my application (WireViz.py) using pip install.
Application and all required modules installed without error and after checking PYTHONPATH, everything is now working.
Thanks for the help.
Short Question:
Is there a way to know the script works the same in 3.4,written in 3.8?
Long Question:
I wrote a script there uses a lot of if and else, when I build it in python 3.8.2, I have test each line myself. But now I need to use py2exe (which only supports till 3.4). So now I want to uninstall my python and install 3.4 but I'm not sure if all my codes will support in it. I started using python from version 3.8 only so I don't know what are the changes that took place from 3.4 to 3.8.2
these are my imports used
import pandas as pd
import eel
import bottle_websocket
import tkinter.filedialog
import xlrd
from configparser import ConfigParser
import os
import time
import xlsxwriter
import json
As I have used too much of if statements, I dont know if some lines inside a if will be executed or not.
You can maintain 2 different environments in the system.
So try running the code in both the environments and see if you get any warnings or errors.
Generally not much will change for the imports you have shared.
I just want to install the suds library, but suddenly it wasn't proceeding because it was not finding the os library, so I tried to open my python and it results me an error. When I import the os library and there are some errors during the opening as well. Please, see the snapshot of my error when importing the library mentioned.
Is there any solution for this? Or do I need to reinstall python?
You need to install a more recent version of Python - version 2.7.12 or later. All versions of Python 2.6 have been end-of-lifed and any use of Python 2.6 is actively discouraged.
The default version of python (ie, one that opens on typing "python" in command line) is 2.6 on my server. I also have 2.7 installed. How do I import a module, in this case numpy, in python2.7? When I try to import right now, it gives me an error -
ImportError: No module named numpy
Is there any workaround, apart from downloading the package and doing a build install?
I agree with the comment above. You will have to compile it separately. I once tried a hack of importing and modifying the sys.path however I ran into issues with the .so files.
Hello I'm trying import a module import Image. I recieved this error <type 'exceptions.ImportError'> Cannot import module 'Image'
I looked for a solution and found this Install Python Module in local install of web2py
So "how can I drop modules in app/modules folder" so web2py will check there first when import something or if anyone knows a better solution then the provided solution please help.
If you are using the Windows or Mac web2py binary, they include their own Python interpreter, so they will not use your system's installed version of Python nor see any of its modules. If you have your own version of Python installed, you're better off running web2py from source, which is just as easy (just download and unzip -- run with the web2py.py file rather than web2py.exe or web2py.app).