Pyfhel icon indicating copy to clipboard operation
Pyfhel copied to clipboard

Installing Pyfhel v2.3.1 "error: ‘unique_lock’ in namespace ‘std’ does not name a template type" [duplicate]

Open SerhatBah opened this issue 3 years ago • 9 comments

Hi.. i cannot manage the paramters of contextGen like the ((scheme)) type, and ((t_bits)).. Also i cannot enter ((p value)) with 13 Digit Number the maximum is 9 digit number.. it gives me an error from 10 digits and up, is that normal? or this is a package problem? How can i solve it, thanks in advance.

Code: HE.contextGen(scheme='bfv', t=214047853, n=2**14, t_bits=20) # 2^14 Errors:

File "C:\Users\LEGION\anaconda3\envs\cryptonets_1\pyfhel_Example_1.py", line 7, in <module>
    HE.contextGen(scheme='bfv', t=214047853, n=2**14, t_bits=20)    

  File "Pyfhel/Pyfhel.pyx", line 182, in Pyfhel.Pyfhel.Pyfhel.contextGen

TypeError: contextGen() takes at least 1 positional argument (0 given)
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
Code: HE.contextGen(scheme='bfv', p=214047853, n=2**14, p_bits=20)   

TypeError: contextGen() got an unexpected keyword argument 'scheme'  --> when using the following
HE.contextGen(scheme='bfv', p=214047853, n=2**14, p_bits=20)

Only this code is working: #HE.contextGen(p=65537, m=2**13)

Any suggestions, thanks in advance. Spyder Ide version: 5.1.5 pyfhel_Example_1.py.txt

Pyfhel: 2.3.1 Python Ver.: 3.7.13 OS: windows 10 64-bits

SerhatBah avatar Aug 02 '22 14:08 SerhatBah

It seems this same issue was already risen in #104 .

Besides, I strongly suggest upgrading to more recent versions of Pyfhel (3+), since older versions (<3) are not maintained.

ibarrond avatar Aug 02 '22 14:08 ibarrond

Many thanks for the quick response. Unfortunately that didn't work for me. We also have different error messages. I'm using Python 3.10, which is the latest version, so that shouldn't be the cause.

I have cloned Pyfhel 2.3.1 and want to install it using the pip install . command. But I always get this error message:

user@TPL15:~/Downloads/Pyfhel-2.3.1 python3 setup.py install
Traceback (most recent call last):
  File "/home/user/Downloads/Pyfhel-2.3.1/setup.py", line 69, in <module>
    local_sources = scan_cpp(SEAL_PATH,[str(AFHEL_PATH / 'Afseal.cpp')])
  File "/home/user/Downloads/Pyfhel-2.3.1/setup.py", line 62, in scan_cpp
    for file in os.listdir(dir):
FileNotFoundError: [Errno 2] No such file or directory: 'Pyfhel/SEAL/SEAL/seal'
user@TPL15:~/Downloads/Pyfhel-2.3.1$ pip3 install .
Defaulting to user installation because normal site-packages is not writeable
Processing /home/user/Downloads/Pyfhel-2.3.1
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error
  
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [20 lines of output]
      Traceback (most recent call last):
        File "/home/user/.local/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
          main()
        File "/home/user/.local/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/home/user/.local/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 130, in get_requires_for_build_wheel
          return hook(config_settings)
        File "/usr/lib/python3/dist-packages/setuptools/build_meta.py", line 162, in get_requires_for_build_wheel
          return self._get_build_requires(
        File "/usr/lib/python3/dist-packages/setuptools/build_meta.py", line 143, in _get_build_requires
          self.run_setup()
        File "/usr/lib/python3/dist-packages/setuptools/build_meta.py", line 267, in run_setup
          super(_BuildMetaLegacyBackend,
        File "/usr/lib/python3/dist-packages/setuptools/build_meta.py", line 158, in run_setup
          exec(compile(code, __file__, 'exec'), locals())
        File "setup.py", line 69, in <module>
          local_sources = scan_cpp(SEAL_PATH,[str(AFHEL_PATH / 'Afseal.cpp')])
        File "setup.py", line 62, in scan_cpp
          for file in os.listdir(dir):
      FileNotFoundError: [Errno 2] No such file or directory: 'Pyfhel/SEAL/SEAL/seal'
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

And via Python Packages in PyCharm, the error message appears as shown above. Can it have something to do with SEAL? I installed it normally on my home directory. Thanks in advance

SerhatBah avatar Aug 02 '22 15:08 SerhatBah

Ok, so your new error message (the first line where the error word appears after the Traceback) is FileNotFoundError: [Errno 2] No such file or directory: 'Pyfhel/SEAL/SEAL/seal'.

Once again, this is an existing error in the list of issues of this repository. If you just search for it directly in the Pyfhel Issues search bar, it will lead you to #41, which will likely help you solve it.

ibarrond avatar Aug 02 '22 15:08 ibarrond

I really searched and read through everything. #41 was even the first. Unfortunately it didn't solve my problem.

The command:

git submodule update --init --recursive

hasn't changed anything.

And when I type this:

git clone --recursive https://github.com/ibarrond/Pyfhel.git

then I get the latest version of Pyfhel. But I need version 2.3.1. Is there no other solution to the problem?

SerhatBah avatar Aug 02 '22 15:08 SerhatBah

Oh ok! To clone the particular tag/version you seek, just run: git clone --recursive https://github.com/ibarrond/Pyfhel.git --branch=v2.3.1

There must be a way to checkout a tag in an already downloaded repo too.

May I ask, why do you need to use an old version of Pyfhel?

ibarrond avatar Aug 02 '22 15:08 ibarrond

Thank you very much, it works!! I'm facing another problem right now. I think this is the same problem that is being discussed in #133.

I get at the command

user@TPL15:~/Downloads/Pyfhel$ sudo pip3 install .

This error message:

Processing /home/user/Downloads/Pyfhel Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... done Requirement already satisfied: setuptools>=45.0.0 in /usr/lib/python3/dist-packages (from Pyfhel==2.3.1) (59.6.0) Requirement already satisfied: numpy>=1.16.0 in /usr/local/lib/python3.10/dist-packages (from Pyfhel==2.3.1) (1.21.0) Requirement already satisfied: cython>=0.29.2 in /usr/local/lib/python3.10/dist-packages (from Pyfhel==2.3.1) (0.29.32) Building wheels for collected packages: Pyfhel Building wheel for Pyfhel (pyproject.toml) ... error error: subprocess-exited-with-error

× Building wheel for Pyfhel (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [47 lines of output] running bdist_wheel running build running build_py copying Pyfhel/init.py -> build/lib.linux-x86_64-3.10/Pyfhel running build_clib x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -I/usr/include/python3.10 -IPyfhel -IPyfhel/Afhel -IPyfhel/SEAL/SEAL/seal -c Pyfhel/Afhel/Afseal.cpp -o build/temp.linux-x86_64-3.10/Pyfhel/Afhel/Afseal.o -DHAVE_CONFIG_H -std=c++17 -O3 In file included from Pyfhel/Afhel/../SEAL/SEAL/seal/mempool.h:12, from Pyfhel/Afhel/../SEAL/SEAL/seal/memorypoolhandle.h:6, from Pyfhel/Afhel/../SEAL/SEAL/seal/biguint.h:6, from Pyfhel/Afhel/../SEAL/SEAL/seal/bigpoly.h:9, from Pyfhel/Afhel/../SEAL/SEAL/seal/seal.h:3, from Pyfhel/Afhel/Afseal.h:41, from Pyfhel/Afhel/Afseal.cpp:37: Pyfhel/Afhel/../SEAL/SEAL/seal/locks.h:6:1: error: ‘include’ does not name a type 6 | include <shared_mutex> | ^~~~~~~ In file included from Pyfhel/Afhel/../SEAL/SEAL/seal/memorypoolhandle.h:6, from Pyfhel/Afhel/../SEAL/SEAL/seal/biguint.h:6, from Pyfhel/Afhel/../SEAL/SEAL/seal/bigpoly.h:9, from Pyfhel/Afhel/../SEAL/SEAL/seal/seal.h:3, from Pyfhel/Afhel/Afseal.h:41, from Pyfhel/Afhel/Afseal.cpp:37: Pyfhel/Afhel/../SEAL/SEAL/seal/mempool.h:577:21: error: ‘ReaderWriterLocker’ does not name a type 577 | mutable ReaderWriterLocker pools_locker_; | ^~~~~~~~~~~~~~~~~~ Pyfhel/Afhel/../SEAL/SEAL/seal/mempool.h: In member function ‘virtual int64_t seal::util::MemoryPoolMT::pool_count() const’: Pyfhel/Afhel/../SEAL/SEAL/seal/mempool.h:561:17: error: ‘ReaderLock’ was not declared in this scope 561 | ReaderLock lock(pools_locker_.acquire_read()); | ^~~~~~~~~~ In file included from Pyfhel/Afhel/../SEAL/SEAL/seal/seal.h:9, from Pyfhel/Afhel/Afseal.h:41, from Pyfhel/Afhel/Afseal.cpp:37: Pyfhel/Afhel/../SEAL/SEAL/seal/decryptor.h: At global scope: Pyfhel/Afhel/../SEAL/SEAL/seal/decryptor.h:174:23: error: ‘ReaderWriterLocker’ in namespace ‘seal::util’ does not name a type 174 | mutable util::ReaderWriterLocker secret_key_array_locker_; | ^~~~~~~~~~~~~~~~~~ In file included from Pyfhel/Afhel/../SEAL/SEAL/seal/seal.h:15, from Pyfhel/Afhel/Afseal.h:41, from Pyfhel/Afhel/Afseal.cpp:37: Pyfhel/Afhel/../SEAL/SEAL/seal/keygenerator.h:177:23: error: ‘ReaderWriterLocker’ in namespace ‘seal::util’ does not name a type 177 | mutable util::ReaderWriterLocker secret_key_array_locker_; | ^~~~~~~~~~~~~~~~~~ Pyfhel/Afhel/Afseal.cpp: In member function ‘void Afseal::encode(std::vector&, seal::Plaintext&)’: Pyfhel/Afhel/Afseal.cpp:269:21: warning: comparison of integer expressions of different signedness: ‘std::vector::size_type’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare] 269 | if(values.size()>this->crtBuilder->slot_count()){ | ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1 [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for Pyfhel Failed to build Pyfhel ERROR: Could not build wheels for Pyfhel, which is required to install pyproject.toml-based projects

It would be really nice if you could help me with that as well. I need the older Version for a project we are working for and between the versions of Pyfhel are the input parameters different. So the Code is not working with the Version 3.2.1 ...

Thank you

SerhatBah avatar Aug 02 '22 16:08 SerhatBah

Sadly there is little I can do to help beyond what #104 mentioned. Pyfhel==2.3.1 is based on an old version of SEAL, thus I encourage you to drop it and migrate to Pyfhel>=3. I can help you migrate the code. Is your code public?

ibarrond avatar Aug 02 '22 16:08 ibarrond

Hello, Yes, that would be really great of you if you could help me, thank you very much!! Then I could also use the latest Pyfhel version :-) This is the code from my supervisor that I have to work with: https://github.com/ShokofehVS/SeCCA

SerhatBah avatar Aug 03 '22 13:08 SerhatBah

I had a quick look at that repo, and it seems you're encrypting one single value per ciphertext, which is quite an overkill. My first suggestion is to take a look at two demos (num. 2 and 3) in the current repo version, to check whether you could adapt yous solution to a vectorized approach (where you encrypt multiple values inside a single ciphertext).

ibarrond avatar Aug 03 '22 14:08 ibarrond

Closing this issue as the installation problem relates to an old version of Pyfhel.

ibarrond avatar Oct 04 '22 21:10 ibarrond