I guess this question (Import not Working) means the following and it is kind of interesting:
Library A and B are actually grequest and multiprocessing. (I heard) grequest patches socket but multiprocessing can't use the patched version.
I want to use two libraries A and B. The problem is that library A internally imports patched version of library C, but library B internally imports the non-patched version of library C.
libraryA.py:
import numpy as np
def f():
print("patched")
np.array = f
libraryB.py:
import numpy as np
def g():
return np.array([1,2,3])
my_program.py:
import libraryA
import libraryB
libraryB.g()
result (python3 my_program.py):
Traceback (most recent call last):
File "my_program.py", line 3, in <module>
libraryB.g()
File ".../test/libraryB.py", line 3, in g
return np.array([1,2,3])
TypeError: f() takes 0 positional arguments but 1 was given
Problem:
libraryB should use the non-patched version of numpy, but it is using the patched version, and so libraryB.g() in my_program.py breaks. How to fix -this- ?