-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
quantecon.models.__init__.py problem #123
Comments
I went and had a look at the When I changed """
models directory imports
objects imported here will live in the `quantecon.models` namespace
"""
__all__ = ["AssetPrices", "CareerWorkerProblem", "ConsumerProblem",
"JvWorker", "LucasTree", "SearchProblem", "GrowthModel",
"solow"]
from . import solow
from .asset_pricing import AssetPrices
from .career import CareerWorkerProblem
from .ifp import ConsumerProblem
from .jv import JvWorker
from .lucastree import LucasTree
from .odu import SearchProblem
from .optgrowth import GrowthModel I can change back to my root directory, head into
I am really confused now as two fixes that I expected to work (and did work on my machine) have now failed to work for others... |
@spencerlyon2 and @albop Can either (or both) check to see whether you can import from quantecon.models import solow |
Doesn't work for me:
|
@spencerlyon2 Damn. This is bizarre. Did you install a fresh conda environment as described above? |
Strange. I did not install a fresh conda environment last time. However, when I do install a fresh one everything works. Perhaps the cache of some previous installation is not getting cleaned when I installed into my existing env. |
Phew. Serious self-doubt was starting to creep in for a bit! Just to be sure I did another fresh conda environment where I built I then changed the """
models directory imports
objects imported here will live in the `quantecon.models` namespace
"""
__all__ = ["AssetPrices", "CareerWorkerProblem", "ConsumerProblem",
"JvWorker", "LucasTree", "SearchProblem", "GrowthModel",
"solow"]
from . import solow
from .asset_pricing import AssetPrices
from .career import CareerWorkerProblem
from .ifp import ConsumerProblem
from .jv import JvWorker
from .lucastree import LucasTree
from .odu import SearchProblem
from .optgrowth import GrowthModel and everything worked fine: (quantecon-test)Davids-MacBook-Pro:~ drpugh$ cd Downloads/QuantEcon.py/quantecon/models/
(quantecon-test)Davids-MacBook-Pro:models drpugh$ nano __init__.py
(quantecon-test)Davids-MacBook-Pro:models drpugh$ cd
(quantecon-test)Davids-MacBook-Pro:~ drpugh$ ipython
Python 2.7.8 |Anaconda 2.1.0 (x86_64)| (default, Aug 21 2014, 15:21:46)
Type "copyright", "credits" or "license" for more information.
IPython 2.2.0 -- An enhanced Interactive Python.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://binstar.org
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: import quantecon as qe
In [2]: qe.models.
qe.models.AssetPrices qe.models.career
qe.models.CareerWorkerProblem qe.models.ifp
qe.models.ConsumerProblem qe.models.jv
qe.models.GrowthModel qe.models.lucastree
qe.models.JvWorker qe.models.odu
qe.models.LucasTree qe.models.optgrowth
qe.models.SearchProblem qe.models.solow
qe.models.asset_pricing
In [2]: qe.models.solow.
qe.models.solow.CESModel qe.models.solow.cobb_douglas
qe.models.solow.CobbDouglasModel qe.models.solow.impulse_response
qe.models.solow.Model qe.models.solow.model
qe.models.solow.ces
In [2]: qe.models.solow. Perhaps @jstac an/or @cc7768 could create a fresh conda environment and see if that fixed the problem for them as well. |
@spencerlyon2 If creating a fresh conda environment fixes the problem, this raises another issue: which is why is the cached not clearing properly in your dev environments? Did you build your dev environment using the script on the Wiki? I am suspicious about step 5, I was taught (by IPython devs at SciPy 2014) that the magic incantation to install a package in "dev-mode" is to run
from within the directory containing |
I created a fresh conda environment and run into the same problem. @jstac did it work for you? |
Did you create a fresh conda environment using the steps that I outlined above? In particular did you use the
command? Or did you use the instructions on the Wiki? |
I did it both ways and didn't work earlier, but the issue was that I hadn't pulled though (I tried on a different computer yesterday). After pulling (and uncommenting the solow import) it seems to be working for me. Don't know what has changed. |
Still not working from me on either of my two machines: After uncommenting the line
in
Very weird. I don't have any ideas. I'll test it in a fresh environ but in a way the result is moot -- we have to leave those imports out until it's stable in all settings. |
Creating a fresh conda environment, uncommenting |
Can you please try creating a new conda environment using the commands that I suggest above specifically the commands
Then cd into local clone of the repo and run
This is how I was taught to create dev-environment by IPython devs (which is different than instructions currently on the QuantEcon Wiki). I am trying to isolate whether the issue is the difference in the way that we initially created dev environments. |
Another thought that I had is that import statements on your machines might have been using old To test this hypothesis, I suppose that you could delete all of the |
Hi all, installation works and all imports are successful after running
This is a really weird and frustrating bug. We can change the wiki to encourage people to install this way but even so At present @mmcky is off line but he will be back in a day or two. I would like to get his thoughts on this. |
I don't think this is a bug in the code. The bug is in the way that the development environments have been set up for anyone who set them up using the instructions on the Wiki. The command
is not the correct command to use if you want to install a package in "develop" mode. See, for example, this SO post for details. To install in develop mode you should use either
or
or some other equivalent. |
@davidrpugh @jstac I can't figure out what exactly is going on with why these imports are failing. Got some feedback from some other students that they aren't able to I think we can agree that ultimately we want others to be able to install and import the quantecon package by simply typing Those things being said, I'm not sure that it is the |
@davidrpugh Sure, I understand that this isn't a bug in the code per se --- or at least I very much doubt it is. And now we have some information from @cc7768 that it might be an ongoing issue. I strongly agree with @cc7768 that we want people to be able to install with I've asked @mmcky to look into this. Perhaps some fresh eyes will help. |
All, I am worried that we are conflating installation by users and installation by developers: these are two separate processes.
Does anyone disagree with either of these points? I think that failure to set up the development environment so that changes to source files are correctly cached is the source of our present difficulty. As best as I can tell from this thread, everyone that had trouble importing the package was developing a Do we have counter-examples to this hypothesis? |
All, I realized that I hadn't been terribly specific about the important distinction between the commands
and the commands
so here goes. When you install Now if you install Does this make sense? |
So far as I can tell, the Travis CI builds are all passing without issue. If this is true, then this would be another indication that the problem is likely with the way development environments are being set up and not with the code base itself. |
@davidrpugh Thanks for additional comments. They were useful for me. My priority is that the package is stable across all standard environments and all standard installation methods. |
I personally see little difference in installation by developers and installation by users. Ultimately, developers are also users, and I still feel that
I think this is interesting code and we should figure out how to get it seamlessly incorporated. I think there is something going wrong right now and we need to pin down what exactly it is. I'm starting to suspect that the issue lies in the problem with it working inside the QuantEcon.py directory and not working from outside. I think (and this is where my understanding of what @davidrpugh What happens if you don't install with |
Hi All. I have had a look at the repo and I have a few comments below.
I think there are also a few errors in the way the package is currently setup for distribution using
@davidrpugh @cc7768 @jstac @spencerlyon2 Could someone please pull the latest and see if this resolves their issues? Side Comments: You can check version by using the version attribute
Also one easy way to check which source package you have imported is to enter the module in ipython which returns the path
versus this when you are in the
|
@mmcky Great work. Everything now working on both my machines. How about everyone else? |
The error you describe in 1 is exactly what I would have expected you to get if you installed Developing in this way seems terribly inefficient but would work. Seems much easier to just use one of the commands above to install in develop mode. |
@jstac @cc7768 @spencerlyon2 @mmcky I continue to get the same behavior after pulling the new commits from @mmcky as I was previously (which is good because everything was working correctly on my machine to begin with). For completeness I performed two experiments the results of which I report below... Experiment 1: Using instructions on the Wiki...I tried the following commands...
...and then checked the contents of
Note that import statement is commented out. I now head into IPython from root (quantecon-test)Davids-MacBook-Pro:~ drpugh$ ipython
Python 2.7.8 |Anaconda 2.1.0 (x86_64)| (default, Aug 21 2014, 15:21:46)
Type "copyright", "credits" or "license" for more information.
IPython 2.2.0 -- An enhanced Interactive Python.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://binstar.org
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: import quantecon as qe
In [2]: qe.models.
qe.models.AssetPrices qe.models.asset_pricing
qe.models.CareerWorkerProblem qe.models.career
qe.models.ConsumerProblem qe.models.ifp
qe.models.GrowthModel qe.models.jv
qe.models.JvWorker qe.models.lucastree
qe.models.LucasTree qe.models.odu
qe.models.SearchProblem qe.models.optgrowth
In [2]: qe.models.solow
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-2-3c88fd58e5e4> in <module>()
----> 1 qe.models.solow
AttributeError: 'module' object has no attribute 'solow'
In [3]: from quantecon.models import solow
In [4]: solow.
solow.CESModel solow.ces solow.model
solow.CobbDouglasModel solow.cobb_douglas
solow.Model solow.impulse_response
In [4]: solow. I expected to see the Now I uncomment the import statement in
and now I again head into IPython from root (quantecon-test)Davids-MacBook-Pro:~ drpugh$ ipython
Python 2.7.8 |Anaconda 2.1.0 (x86_64)| (default, Aug 21 2014, 15:21:46)
Type "copyright", "credits" or "license" for more information.
IPython 2.2.0 -- An enhanced Interactive Python.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://binstar.org
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: import quantecon as qe
In [2]: qe.models.
qe.models.AssetPrices qe.models.asset_pricing
qe.models.CareerWorkerProblem qe.models.career
qe.models.ConsumerProblem qe.models.ifp
qe.models.GrowthModel qe.models.jv
qe.models.JvWorker qe.models.lucastree
qe.models.LucasTree qe.models.odu
qe.models.SearchProblem qe.models.optgrowth
In [2]: qe.models.solow
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-2-3c88fd58e5e4> in <module>()
----> 1 qe.models.solow
AttributeError: 'module' object has no attribute 'solow'
In [3]: from quantecon.models import solow
In [4]: solow.
solow.CESModel solow.ces solow.model
solow.CobbDouglasModel solow.cobb_douglas
solow.Model solow.impulse_response
In [4]: solow. As expected I get the same results, the changes made to Now if I go back into
Experiment 2: Installing in 'dev' modeI tried the following commands...
...and then checked the contents of
again note that the import statement is commented out. Now head to root and enter IPython (quantecon-test2)Davids-MacBook-Pro:~ drpugh$ ipython
Python 2.7.8 |Anaconda 2.1.0 (x86_64)| (default, Aug 21 2014, 15:21:46)
Type "copyright", "credits" or "license" for more information.
IPython 2.2.0 -- An enhanced Interactive Python.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://binstar.org
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: import quantecon as qe
In [2]: qe.models.
qe.models.AssetPrices qe.models.asset_pricing
qe.models.CareerWorkerProblem qe.models.career
qe.models.ConsumerProblem qe.models.ifp
qe.models.GrowthModel qe.models.jv
qe.models.JvWorker qe.models.lucastree
qe.models.LucasTree qe.models.odu
qe.models.SearchProblem qe.models.optgrowth
In [2]: qe.models.solow
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-2-3c88fd58e5e4> in <module>()
----> 1 qe.models.solow
AttributeError: 'module' object has no attribute 'solow'
In [3]: Same behavior as Experiment 1 with the import statement commented out in the Now I make changes to
and now I again head into IPython from root (quantecon-test2)Davids-MacBook-Pro:~ drpugh$ ipython
Python 2.7.8 |Anaconda 2.1.0 (x86_64)| (default, Aug 21 2014, 15:21:46)
Type "copyright", "credits" or "license" for more information.
IPython 2.2.0 -- An enhanced Interactive Python.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://binstar.org
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: import quantecon as qe
In [2]: qe.models.
qe.models.AssetPrices qe.models.career
qe.models.CareerWorkerProblem qe.models.ifp
qe.models.ConsumerProblem qe.models.jv
qe.models.GrowthModel qe.models.lucastree
qe.models.JvWorker qe.models.odu
qe.models.LucasTree qe.models.optgrowth
qe.models.SearchProblem qe.models.solow
qe.models.asset_pricing
In [2]: qe.models.solow.
qe.models.solow.CESModel qe.models.solow.cobb_douglas
qe.models.solow.CobbDouglasModel qe.models.solow.impulse_response
qe.models.solow.Model qe.models.solow.model
qe.models.solow.ces
In [2]: qe.models.solow. and as expected given that I had installed Hope everyone finds this useful... |
@davidrpugh Agree that it is slightly inefficient -- Mostly just making the point that it should work. It looks like we were all just looking in wrong place. Excited that we are good to go with this code (all of my machines are good now) and I learned a little more about what needs to change when introducing new sub-packages. |
@davidrpugh I installed via I guess we're done here. Thanks everyone for input and thanks again to @mmcky for clearing this up. |
Glad that it is up an running for everyone now. Should I go ahead and close the issue? |
Closing now. |
@jstac
I report your initial error for reference...
Now here is what I have done to try and replicate your error message. I created a completely new
conda
environment using......then changed into my local clone of
quant-econ
and run...... which installs
quantecon
from my local repo in editable mode (i.e., for dev work).Now I check the contents of the offending
__init__.py
script...I then change back to my root, head into
ipython
and am able to importquantecon
and access thesolow
module without issue......I can't replicate your issue on my machine. I did get your email saying that @cc7768 had been able to replicate the issue. I am a bit bamboozled...
The text was updated successfully, but these errors were encountered: