ImportError: cannot import name 'Pyfhel' from 'Pyfhel' - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: ImportError: cannot import name 'Pyfhel' from 'Pyfhel' (/thread-35210.html) |
ImportError: cannot import name 'Pyfhel' from 'Pyfhel' - Anldra12 - Oct-09-2021 I use some recently GitHub publish code ----->https://github.com/ibarrond/Pyfhel it return me error Where Pyfhel i have installed from git command line and as well from terminal shown in the GitHub code readme file and PyPtxt mean plaintext and PyCtxt ciphertext. How to solve this error if i just write from Pyfhel import* instead of from Pyfhel import Pyfhel, PyPtxt, PyCtxt still it give me an error. import time from Pyfhel import Pyfhel, PyPtxt, PyCtxt # Pyfhel class contains most of the functions. # PyPtxt is the plaintext class # PyCtxt is the ciphertext class print("==============================================================") print("================== Pyfhel CONTEXT PARAMETERS =================") print("==============================================================") print("1. p (long): Plaintext modulus. All operations are modulo p. ") HE = Pyfhel() # Creating empty Pyfhel object HE.contextGen(p=65537) # Generating context. The value of p is important. # There are many configurable parameters on this step HE.keyGen() # Key Generation. print("2. m (long=2048): Polynomial coefficient modulus.") print(" Higher allows more encrypted operations. In batch mode it is the number of integers per ciphertext.") def time_demo_helloworld(integer1=127, integer2=-2): start = time.time() ctxt1 = HE.encryptInt(integer1) # Encryption makes use of the public key ctxt2 = HE.encryptInt(integer2) # For integers, encryptInt function is used. ctxtSum = ctxt1 + ctxt2 # `ctxt1 += ctxt2` for quicker inplace operation ctxtSub = ctxt1 - ctxt2 # `ctxt1 -= ctxt2` for quicker inplace operation ctxtMul = ctxt1 * ctxt2 # `ctxt1 *= ctxt2` for quicker inplace operation resSum = HE.decryptInt(ctxtSum) resSub = HE.decryptInt(ctxtSub) resMul = HE.decryptInt(ctxtMul) end = time.time() print(f"Elapsed time: {end - start}") results = (resSum==125, resSub==129, resMul==-254) return end - start, resultsError: Process finished with exit code 1
RE: ImportError: cannot import name 'Pyfhel' from 'Pyfhel' - Larz60+ - Oct-09-2021 install instructions from PyPi (on command line, not 'git command line'), page: pip install Pyfhel
RE: ImportError: cannot import name 'Pyfhel' from 'Pyfhel' - Anldra12 - Oct-10-2021 @Larz60+ i follow the sample procedure to install Pyfhel https://pypi.org/project/Pyfhel/ and install it where still it give me the same error PyPl installation i have done the follow command by using Linux 1) git clone --recursive https://github.com/ibarrond/Pyfhel.git 2) pip install RE: ImportError: cannot import name 'Pyfhel' from 'Pyfhel' - Larz60+ - Oct-10-2021 To use the method that you are showing, and after the clone, the pip command has to be pip install . you need the ' .' after 'pip install' the method I show is to go to the command line, and then type verbatim: pip install Pyfhel
RE: ImportError: cannot import name 'Pyfhel' from 'Pyfhel' - Underscore - Oct-11-2021 install it using pip/pip3 RE: ImportError: cannot import name 'Pyfhel' from 'Pyfhel' - Anldra12 - Oct-11-2021 Install done accordingly PyPl but still the same import error for all demo 1) git clone --recursive https://github.com/ibarrond/Pyfhel.git 2) pip install . 3) pip install Pyphel here is share my installing link screen shot of Linux have a look--------> https://ibb.co/FWj60mN RE: ImportError: cannot import name 'Pyfhel' from 'Pyfhel' - snippsat - Oct-12-2021 You get a error message normal site-packages is not writeable This can be a permission problem or Python/pip problem. If you do pip -V and python3 -V dos both point to Python 3.8?Try install with python3 -m pip install Pyfhel If type python3 terminal dos python 3.8 start? it look like it install ok to 3.8. Then test with from Pyfhel import Pyfhel, PyPtxt, PyCtxt I know you struggle with this basic command line stuff as shown in you last post. Here a run with virtual environment (build into Python) which is the best way to try if struggle or use in general.# Make tom@tom-VirtualBox:~$ python -m venv pyhel_env # cd in tom@tom-VirtualBox:~$ cd pyhel_env/ # Activate tom@tom-VirtualBox:~/pyhel_env$ source bin/activate # Test python (pyhel_env) tom@tom-VirtualBox:~/pyhel_env$ python -V Python 3.9.6 # Test pip,see it point this folder (pyhel_env) tom@tom-VirtualBox:~/pyhel_env$ pip -V pip 21.1.3 from /home/tom/pyhel_env/lib/python3.9/site-packages/pip (python 3.9) # Install (pyhel_env) tom@tom-VirtualBox:~/pyhel_env$ pip install Pyfhel Collecting Pyfhel Downloading Pyfhel-2.3.1.tar.gz (716 kB) ..... Successfully installed Pyfhel-2.3.1 cython-0.29.24 numpy-1.21.2 # Test that is work (pyhel_env) tom@tom-VirtualBox:~/pyhel_env$ python Python 3.9.6 (default, Aug 3 2021, 16:49:17) [GCC 7.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> from Pyfhel import Pyfhel, PyPtxt, PyCtxt >>> >>> Pyfhel <class 'Pyfhel.Pyfhel.Pyfhel'> >>> exit() RE: ImportError: cannot import name 'Pyfhel' from 'Pyfhel' - Anldra12 - Oct-12-2021 100% right what you suggest but have look ----> https://ibb.co/8dwTHh1 installation is done but still return the same error. RE: ImportError: cannot import name 'Pyfhel' from 'Pyfhel' - snippsat - Oct-12-2021 You most type python3 not python.Then you test import. from Pyfhel import Pyfhel, PyPtxt, PyCtxt RE: ImportError: cannot import name 'Pyfhel' from 'Pyfhel' - Anldra12 - Dec-13-2021 The Error has been solved @snippsat and Larz60+ many thanks brothers. |