QuantLib on Python in PyCharm on Mac

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

QuantLib on Python in PyCharm on Mac

Jeff C
Hi,

When I initially "import QuantLib as ql" I don't get an error and PyCharm even gives me the short cut to type QuantLib. But after a second PyCharm gives me this error:

Unused import statement.
This inspection detects names that should resolve but don't. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases. Top-level and class-level items are supported better than instance items.

The download and installation guide mentions something about "disabling shared" if you only want to use Python, but I want to also have access to QuantLib in C++. Does anyone know what this means and how to fix it?

Thanks!
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: QuantLib on Python in PyCharm on Mac

Luigi Ballabio
PyCharm is telling you that you imported the module but didn't use it anywhere.  It's just a warning, and it should disappear as soon as you use anything from ql.

Luigi


On Wed, May 24, 2017 at 3:27 AM Jeff C <[hidden email]> wrote:
Hi,

When I initially "import QuantLib as ql" I don't get an error and PyCharm
even gives me the short cut to type QuantLib. But after a second PyCharm
gives me this error:

Unused import statement.
This inspection detects names that should resolve but don't. Due to dynamic
dispatch and duck typing, this is possible in a limited but useful number of
cases. Top-level and class-level items are supported better than instance
items.

The download and installation guide mentions something about "disabling
shared" if you only want to use Python, but I want to also have access to
QuantLib in C++. Does anyone know what this means and how to fix it?

Thanks!



--
View this message in context: http://quantlib.10058.n7.nabble.com/QuantLib-on-Python-in-PyCharm-on-Mac-tp18304.html
Sent from the quantlib-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: QuantLib on Python in PyCharm on Mac

Jeff C
I wrote a simple piece of code, but I am still getting the same error as before if my mouse hovers over the import QuantLib as ql.

Input:
import QuantLib as ql

date = ql.Date(7, 3, 2015)
print(date)

Output:
/anaconda/bin/python3.6 /Users/jeffcalhou/PycharmProjects/QuantLib/QuantLib.py
Traceback (most recent call last):
  File "/Users/jeffcalhou/PycharmProjects/QuantLib/QuantLib.py", line 1, in <module>
    import QuantLib as ql
  File "/Users/jeffcalhou/PycharmProjects/QuantLib/QuantLib.py", line 3, in <module>
    date = ql.Date(7, 3, 2015)
AttributeError: module 'QuantLib' has no attribute 'Date'

Process finished with exit code 1

Instead of printing March 3rd, 2015
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: QuantLib on Python in PyCharm on Mac

Luigi Ballabio
Where does /Users/jeffcalhou/PycharmProjects/QuantLib/QuantLib.py come from? It is the one distributed in QuantLib-SWIG-1.10.tar.gz?

Luigi


On Thu, May 25, 2017 at 5:17 PM Jeff C <[hidden email]> wrote:
I wrote a simple piece of code, but I am still getting the same error as
before if my mouse hovers over the import QuantLib as ql.

Input:
import QuantLib as ql

date = ql.Date(7, 3, 2015)
print(date)

Output:
/anaconda/bin/python3.6
/Users/jeffcalhou/PycharmProjects/QuantLib/QuantLib.py
Traceback (most recent call last):
  File "/Users/jeffcalhou/PycharmProjects/QuantLib/QuantLib.py", line 1, in
<module>
    import QuantLib as ql
  File "/Users/jeffcalhou/PycharmProjects/QuantLib/QuantLib.py", line 3, in
<module>
    date = ql.Date(7, 3, 2015)
AttributeError: module 'QuantLib' has no attribute 'Date'

Process finished with exit code 1

Instead of printing March 3rd, 2015



--
View this message in context: http://quantlib.10058.n7.nabble.com/QuantLib-on-Python-in-PyCharm-on-Mac-tp18304p18306.html
Sent from the quantlib-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: QuantLib on Python in PyCharm on Mac

Jeff C
I deleted the file and ran the code again and everything works. It must have been a PyCharm issue. Thanks for the help.
Loading...