|
From: Christofer B. <bog...@gm...> - 2020-08-14 09:18:59
|
This worked. Many thanks for this suggestion. Regards, On Fri, Aug 14, 2020 at 1:07 PM Luigi Ballabio <lui...@gm...> wrote: > Christofer, > I suspect at this point you have broken pieces of installation lying > around from three different Python versions and interfering with your new > attempts. I suggest you use virtualenv to create a clean environment and > work in that one. It's a good practice anyway. > > Whatever version of python3 you want to use, create a new work directory, > enter it in the terminal, and run: > > python3 -m venv ql-env > > this will create a new directory ql-env with a clean Python environment > (based on the version you used). You don't need to enter in the directory: > stay where you are. To activate the new environment, run: > > . ql-env/bin/activate > > > (notice the single dot at the beginning followed by a space - that's > actually a command). Your shell prompt should now have a (ql-env) at the > beginning to show that you're in the new environment. Now, when you use > python or pip (or python3 or pip3) you'll get the versions in the > environment. To check, you can try: > > pip list > > which should return only pip and setuptools and no other module (because > the new environment is clean). Now finally try: > > pip install QuantLib > > which should hopefully work. If it does, install into the environment the > other modules you need. > > The new environment is only active in the shell you're using; any other > shell and program using Python will still use the default one. Also, if > you exit the terminal and later you come back and want to work in the > environment, you'll have to repeat the "activate" step above. > > Hope this helps, > Luigi > > > > On Thu, Aug 13, 2020 at 8:45 PM Christofer Bogaso < > bog...@gm...> wrote: > >> Appears to me that installing Quantlib in Mac-Python3 is >> frustratingly difficult and there are many breakpoints. >> >> I reinstalled Python and QuantLib altogether. With the new installation - >> >> >>> import sys >> >> >>> sys.path >> >> ['', >> '/Library/Frameworks/Python.framework/Versions/3.6/lib/python36.zip', >> '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6', >> '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/lib-dynload', >> '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages', >> '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/setuptools-33.1.1-py3.6.egg'] >> >> >>> import QuantLib >> >> Traceback (most recent call last): >> >> File "<stdin>", line 1, in <module> >> >> File >> "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/QuantLib/__init__.py", >> line 21, in <module> >> >> from .QuantLib import * >> >> File >> "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/QuantLib/QuantLib.py", >> line 13, in <module> >> >> from . import _QuantLib >> >> ImportError: cannot import name '_QuantLib' >> >> And now it is failing with a new reason!!! >> >> >> On Thu, Aug 13, 2020 at 11:11 PM Luigi Ballabio <lui...@gm...> >> wrote: >> >>> From inside Python, try >>> >>> import sys >>> print(sys.path) >>> >>> The list you get should include /usr/local/lib/python3.8/site-packages, >>> where pip3 installed QuantLib. If not, you might have some configuration >>> to do. >>> >>> On Thu, Aug 13, 2020 at 7:09 PM Christofer Bogaso < >>> bog...@gm...> wrote: >>> >>>> It would be better if I can load QuantLin with Python3. >>>> >>>> I failed to use some of the packages with Python2 (2.7.16) like >>>> matplotlib. Thanks, >>>> >>>> On Thu, Aug 13, 2020 at 8:09 PM Javid Ashraff <jav...@ya...> >>>> wrote: >>>> >>>>> I recall having the same problem in the past. Try using pip install >>>>> rather than pip3 install. >>>>> >>>>> Regards, >>>>> >>>>> Javid >>>>> >>>>> On Thursday, 13 August 2020, 19:15:32 GMT+8, Christofer Bogaso < >>>>> bog...@gm...> wrote: >>>>> >>>>> >>>>> Thanks. >>>>> >>>>> I have reinstalled Python3 using brew. And then installed again the >>>>> QuantLib as below - >>>>> >>>>> pip3 install QuantLib-Python >>>>> >>>>> Requirement already satisfied: QuantLib-Python in >>>>> /usr/local/lib/python3.8/site-packages (1.18) >>>>> >>>>> Requirement already satisfied: QuantLib in >>>>> /usr/local/lib/python3.8/site-packages (from QuantLib-Python) (1.19) >>>>> >>>>> After that I tried to import the library within Python3, but failed. >>>>> >>>>> >>> import QuantLib as ql >>>>> >>>>> Traceback (most recent call last): >>>>> >>>>> File "<stdin>", line 1, in <module> >>>>> >>>>> ModuleNotFoundError: No module named 'QuantLib' >>>>> >>>>> Any idea why is it failing? >>>>> >>>>> On Thu, Aug 13, 2020 at 4:36 PM Luigi Ballabio < >>>>> lui...@gm...> wrote: >>>>> >>>>> I don't think there is. You'll probably have to remove the *build/bdist.macosx-10.15-x86_64/egg/ >>>>> *directory. To be sure you're not missing anything, you might also >>>>> run "pip uninstall QuantLib-Python" first, then look for anything related >>>>> to QuantLib in /usr/local/lib and its Python subdirectories. Once you >>>>> clean them (but be careful to only clean stuff with "quantlib" in its >>>>> name), you can run "pip install" again. >>>>> >>>>> Luigi >>>>> >>>>> >>>>> On Thu, Aug 13, 2020 at 12:00 PM Christofer Bogaso < >>>>> bog...@gm...> wrote: >>>>> >>>>> Thanks Luigi. But, how can I clean that? Is there any specific syntax? >>>>> >>>>> On Thu, Aug 13, 2020 at 3:19 PM Luigi Ballabio < >>>>> lui...@gm...> wrote: >>>>> >>>>> Hello, >>>>> from the fact the traceback starts from " >>>>> *build/bdist.macosx-10.15-x86_64/egg/"* and the fact it refers to >>>>> */usr/local/lib/libQuantLib.0.dylib,* it looks to me like it's >>>>> importing a version you tried to compile rather than the one you installed >>>>> with pip. If that's the case, I'd try cleaning that one up. >>>>> >>>>> Hope this helps, >>>>> Luigi >>>>> >>>>> >>>>> On Thu, Aug 13, 2020 at 11:35 AM Christofer Bogaso < >>>>> bog...@gm...> wrote: >>>>> >>>>> Hi, >>>>> >>>>> I wanted to run QuantLib from my Python workplace, however failed to >>>>> import the library with below error - >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> *>>> import QuantLibTraceback (most recent call last): File >>>>> "<stdin>", line 1, in <module> File >>>>> "build/bdist.macosx-10.15-x86_64/egg/QuantLib/__init__.py", line 24, in >>>>> <module> File "build/bdist.macosx-10.15-x86_64/egg/QuantLib/QuantLib.py", >>>>> line 13, in <module> File >>>>> "build/bdist.macosx-10.15-x86_64/egg/QuantLib/_QuantLib.py", line 7, in >>>>> <module> File "build/bdist.macosx-10.15-x86_64/egg/QuantLib/_QuantLib.py", >>>>> line 6, in __bootstrap__ImportError: >>>>> dlopen(/Users/aa/Library/Caches/Python-Eggs/QuantLib_Python-1.16.1-py2.7-macosx-10.15-x86_64.egg-tmp/QuantLib/_QuantLib.so, >>>>> 2): Symbol not found: >>>>> __ZN8QuantLib10IborCouponC1ERKNS_4DateEdS3_S3_jRKN5boost10shared_ptrINS_9IborIndexEEEddS3_S3_RKNS_10DayCounterEb >>>>> Referenced from: >>>>> /Users/aa/Library/Caches/Python-Eggs/QuantLib_Python-1.16.1-py2.7-macosx-10.15-x86_64.egg-tmp/QuantLib/_QuantLib.so >>>>> Expected in: /usr/local/lib/libQuantLib.0.dylib in >>>>> /Users/aa/Library/Caches/Python-Eggs/QuantLib_Python-1.16.1-py2.7-macosx-10.15-x86_64.egg-tmp/QuantLib/_QuantLib.so* >>>>> >>>>> I used the syntax *pip install QuantLib-Python* when I installed >>>>> QuantLib, the installation appears to be successful. >>>>> >>>>> Any help will be highly appreciated. >>>>> >>>>> Thanks, >>>>> _______________________________________________ >>>>> QuantLib-users mailing list >>>>> Qua...@li... >>>>> https://lists.sourceforge.net/lists/listinfo/quantlib-users >>>>> >>>>> _______________________________________________ >>>>> QuantLib-users mailing list >>>>> Qua...@li... >>>>> https://lists.sourceforge.net/lists/listinfo/quantlib-users >>>>> >>>> |