Why is this Deprication Warning halting code execution?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I tried to use the TfidifVectorizer and CountVectorizer from the Sci-Kit Learn package, but when I import them:
from sklearn.feature_extraction.text import TfidfVectorizer, CountVectorizer



I get the following warning message:




/anaconda3/lib/python3.7/site-packages/sklearn/feature_extraction/text.py:17: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
from collections import Mapping, defaultdict




My code stops running after this even though the message is just a warning, indicating that an error arises (even though no error is reported back). I suppose this is the true reason I am asking about the warning because it is all that I have to go off of.
Is this a bug with SKLearn? Since the update to python 3.7, are the developers behind? Any suggestions on whether I should report this, or how to revert to python 3.6 using anaconda to get around this would be greatly appreciated. Thank you!










share|improve this question























  • Which version of sklearn are you using?

    – Vivek Kumar
    Nov 26 '18 at 14:44


















0















I tried to use the TfidifVectorizer and CountVectorizer from the Sci-Kit Learn package, but when I import them:
from sklearn.feature_extraction.text import TfidfVectorizer, CountVectorizer



I get the following warning message:




/anaconda3/lib/python3.7/site-packages/sklearn/feature_extraction/text.py:17: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
from collections import Mapping, defaultdict




My code stops running after this even though the message is just a warning, indicating that an error arises (even though no error is reported back). I suppose this is the true reason I am asking about the warning because it is all that I have to go off of.
Is this a bug with SKLearn? Since the update to python 3.7, are the developers behind? Any suggestions on whether I should report this, or how to revert to python 3.6 using anaconda to get around this would be greatly appreciated. Thank you!










share|improve this question























  • Which version of sklearn are you using?

    – Vivek Kumar
    Nov 26 '18 at 14:44














0












0








0








I tried to use the TfidifVectorizer and CountVectorizer from the Sci-Kit Learn package, but when I import them:
from sklearn.feature_extraction.text import TfidfVectorizer, CountVectorizer



I get the following warning message:




/anaconda3/lib/python3.7/site-packages/sklearn/feature_extraction/text.py:17: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
from collections import Mapping, defaultdict




My code stops running after this even though the message is just a warning, indicating that an error arises (even though no error is reported back). I suppose this is the true reason I am asking about the warning because it is all that I have to go off of.
Is this a bug with SKLearn? Since the update to python 3.7, are the developers behind? Any suggestions on whether I should report this, or how to revert to python 3.6 using anaconda to get around this would be greatly appreciated. Thank you!










share|improve this question














I tried to use the TfidifVectorizer and CountVectorizer from the Sci-Kit Learn package, but when I import them:
from sklearn.feature_extraction.text import TfidfVectorizer, CountVectorizer



I get the following warning message:




/anaconda3/lib/python3.7/site-packages/sklearn/feature_extraction/text.py:17: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
from collections import Mapping, defaultdict




My code stops running after this even though the message is just a warning, indicating that an error arises (even though no error is reported back). I suppose this is the true reason I am asking about the warning because it is all that I have to go off of.
Is this a bug with SKLearn? Since the update to python 3.7, are the developers behind? Any suggestions on whether I should report this, or how to revert to python 3.6 using anaconda to get around this would be greatly appreciated. Thank you!







python scikit-learn feature-extraction






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 23 '18 at 23:44









Dave LDave L

228




228













  • Which version of sklearn are you using?

    – Vivek Kumar
    Nov 26 '18 at 14:44



















  • Which version of sklearn are you using?

    – Vivek Kumar
    Nov 26 '18 at 14:44

















Which version of sklearn are you using?

– Vivek Kumar
Nov 26 '18 at 14:44





Which version of sklearn are you using?

– Vivek Kumar
Nov 26 '18 at 14:44












1 Answer
1






active

oldest

votes


















1














It's highly unlikely that this deprecation warning is causing an issue. By default, all warnings just print a message and then continue. Warnings can be treated as exceptions, but then you'd see a stacktrace instead of the warning text. Deprecation warnings are meant for developers, to inform them that their library will break for future python releases. They are not meant for end users, as the code still works perfectly fine. Case in point, as per the warning, from collections import Mapping, defaultdict still works in your version of python (3.7), but won't in python 3.8.



As such, this warning is unlikely to be the source of the problem. That you are seeing it is because sklearn changes the default warning filters so that it users will see deprecation warnings issued by sklearn.
Warnings don't change the execution flow unless they are set to be treated as errors.
To verify that the warning is not the problem you could try running your program in a this harness. It's rather hacky, but it's required to stop sklearn overriding the default warning filters. By playing around with the values of the warning filter you should be able to see that the deprecation warning is not the source of your problem.



import warnings
from warnings import (
filterwarnings as original_filterwarnings,
simplefilter as original_simplefilter
)

def ignore_filterwarnings(*args, **kwargs):
pass

def ignore_simplefilter(*args, **kwargs):
pass

warnings.filterwarnings = ignore_filterwarnings
warnings.simplefilter = ignore_simplefilter

# no imports of sklearn should occur before the previous two lines (otherwise sklearn
# will get to use the original functions).

with warnings.catch_warnings():
original_simplefilter("ignore") # or "error" to see the difference

from my_main_module import main
main()





share|improve this answer
























  • Thank you for the reply. I think that I need to investigate further into the code that I am working with. When I run it on my personal computer on a sample of data, I get the desired output. However, when I run it on the remote computer that houses a larger dataset I am using, I get the Deprication Warning and then the program closes with no indication as to why. I silenced the warnings by adding the shebang '#!/usr/bin/env python -W ignore::DeprecationWarning' to see if anything else could be discovered. I will definitely try your code to see if I can catch anything.

    – Dave L
    Nov 24 '18 at 4:08











  • You might have a version mismatch. It looks like the deprecation warning was fixed as part of 0.20.0, so if you see it on one machine and not another then it would safe to assume the machines have different setups. You should probably investigate how versions of your local and remote machines differ.

    – Dunes
    Nov 24 '18 at 13:53













  • My personal machine has python 3.6, so that is why I thought that I might need to roll back the version of python on the other machine or update my packages. But I will certainly investigate this. Thank you very much for your help.

    – Dave L
    Nov 24 '18 at 14:25












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53453959%2fwhy-is-this-deprication-warning-halting-code-execution%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














It's highly unlikely that this deprecation warning is causing an issue. By default, all warnings just print a message and then continue. Warnings can be treated as exceptions, but then you'd see a stacktrace instead of the warning text. Deprecation warnings are meant for developers, to inform them that their library will break for future python releases. They are not meant for end users, as the code still works perfectly fine. Case in point, as per the warning, from collections import Mapping, defaultdict still works in your version of python (3.7), but won't in python 3.8.



As such, this warning is unlikely to be the source of the problem. That you are seeing it is because sklearn changes the default warning filters so that it users will see deprecation warnings issued by sklearn.
Warnings don't change the execution flow unless they are set to be treated as errors.
To verify that the warning is not the problem you could try running your program in a this harness. It's rather hacky, but it's required to stop sklearn overriding the default warning filters. By playing around with the values of the warning filter you should be able to see that the deprecation warning is not the source of your problem.



import warnings
from warnings import (
filterwarnings as original_filterwarnings,
simplefilter as original_simplefilter
)

def ignore_filterwarnings(*args, **kwargs):
pass

def ignore_simplefilter(*args, **kwargs):
pass

warnings.filterwarnings = ignore_filterwarnings
warnings.simplefilter = ignore_simplefilter

# no imports of sklearn should occur before the previous two lines (otherwise sklearn
# will get to use the original functions).

with warnings.catch_warnings():
original_simplefilter("ignore") # or "error" to see the difference

from my_main_module import main
main()





share|improve this answer
























  • Thank you for the reply. I think that I need to investigate further into the code that I am working with. When I run it on my personal computer on a sample of data, I get the desired output. However, when I run it on the remote computer that houses a larger dataset I am using, I get the Deprication Warning and then the program closes with no indication as to why. I silenced the warnings by adding the shebang '#!/usr/bin/env python -W ignore::DeprecationWarning' to see if anything else could be discovered. I will definitely try your code to see if I can catch anything.

    – Dave L
    Nov 24 '18 at 4:08











  • You might have a version mismatch. It looks like the deprecation warning was fixed as part of 0.20.0, so if you see it on one machine and not another then it would safe to assume the machines have different setups. You should probably investigate how versions of your local and remote machines differ.

    – Dunes
    Nov 24 '18 at 13:53













  • My personal machine has python 3.6, so that is why I thought that I might need to roll back the version of python on the other machine or update my packages. But I will certainly investigate this. Thank you very much for your help.

    – Dave L
    Nov 24 '18 at 14:25
















1














It's highly unlikely that this deprecation warning is causing an issue. By default, all warnings just print a message and then continue. Warnings can be treated as exceptions, but then you'd see a stacktrace instead of the warning text. Deprecation warnings are meant for developers, to inform them that their library will break for future python releases. They are not meant for end users, as the code still works perfectly fine. Case in point, as per the warning, from collections import Mapping, defaultdict still works in your version of python (3.7), but won't in python 3.8.



As such, this warning is unlikely to be the source of the problem. That you are seeing it is because sklearn changes the default warning filters so that it users will see deprecation warnings issued by sklearn.
Warnings don't change the execution flow unless they are set to be treated as errors.
To verify that the warning is not the problem you could try running your program in a this harness. It's rather hacky, but it's required to stop sklearn overriding the default warning filters. By playing around with the values of the warning filter you should be able to see that the deprecation warning is not the source of your problem.



import warnings
from warnings import (
filterwarnings as original_filterwarnings,
simplefilter as original_simplefilter
)

def ignore_filterwarnings(*args, **kwargs):
pass

def ignore_simplefilter(*args, **kwargs):
pass

warnings.filterwarnings = ignore_filterwarnings
warnings.simplefilter = ignore_simplefilter

# no imports of sklearn should occur before the previous two lines (otherwise sklearn
# will get to use the original functions).

with warnings.catch_warnings():
original_simplefilter("ignore") # or "error" to see the difference

from my_main_module import main
main()





share|improve this answer
























  • Thank you for the reply. I think that I need to investigate further into the code that I am working with. When I run it on my personal computer on a sample of data, I get the desired output. However, when I run it on the remote computer that houses a larger dataset I am using, I get the Deprication Warning and then the program closes with no indication as to why. I silenced the warnings by adding the shebang '#!/usr/bin/env python -W ignore::DeprecationWarning' to see if anything else could be discovered. I will definitely try your code to see if I can catch anything.

    – Dave L
    Nov 24 '18 at 4:08











  • You might have a version mismatch. It looks like the deprecation warning was fixed as part of 0.20.0, so if you see it on one machine and not another then it would safe to assume the machines have different setups. You should probably investigate how versions of your local and remote machines differ.

    – Dunes
    Nov 24 '18 at 13:53













  • My personal machine has python 3.6, so that is why I thought that I might need to roll back the version of python on the other machine or update my packages. But I will certainly investigate this. Thank you very much for your help.

    – Dave L
    Nov 24 '18 at 14:25














1












1








1







It's highly unlikely that this deprecation warning is causing an issue. By default, all warnings just print a message and then continue. Warnings can be treated as exceptions, but then you'd see a stacktrace instead of the warning text. Deprecation warnings are meant for developers, to inform them that their library will break for future python releases. They are not meant for end users, as the code still works perfectly fine. Case in point, as per the warning, from collections import Mapping, defaultdict still works in your version of python (3.7), but won't in python 3.8.



As such, this warning is unlikely to be the source of the problem. That you are seeing it is because sklearn changes the default warning filters so that it users will see deprecation warnings issued by sklearn.
Warnings don't change the execution flow unless they are set to be treated as errors.
To verify that the warning is not the problem you could try running your program in a this harness. It's rather hacky, but it's required to stop sklearn overriding the default warning filters. By playing around with the values of the warning filter you should be able to see that the deprecation warning is not the source of your problem.



import warnings
from warnings import (
filterwarnings as original_filterwarnings,
simplefilter as original_simplefilter
)

def ignore_filterwarnings(*args, **kwargs):
pass

def ignore_simplefilter(*args, **kwargs):
pass

warnings.filterwarnings = ignore_filterwarnings
warnings.simplefilter = ignore_simplefilter

# no imports of sklearn should occur before the previous two lines (otherwise sklearn
# will get to use the original functions).

with warnings.catch_warnings():
original_simplefilter("ignore") # or "error" to see the difference

from my_main_module import main
main()





share|improve this answer













It's highly unlikely that this deprecation warning is causing an issue. By default, all warnings just print a message and then continue. Warnings can be treated as exceptions, but then you'd see a stacktrace instead of the warning text. Deprecation warnings are meant for developers, to inform them that their library will break for future python releases. They are not meant for end users, as the code still works perfectly fine. Case in point, as per the warning, from collections import Mapping, defaultdict still works in your version of python (3.7), but won't in python 3.8.



As such, this warning is unlikely to be the source of the problem. That you are seeing it is because sklearn changes the default warning filters so that it users will see deprecation warnings issued by sklearn.
Warnings don't change the execution flow unless they are set to be treated as errors.
To verify that the warning is not the problem you could try running your program in a this harness. It's rather hacky, but it's required to stop sklearn overriding the default warning filters. By playing around with the values of the warning filter you should be able to see that the deprecation warning is not the source of your problem.



import warnings
from warnings import (
filterwarnings as original_filterwarnings,
simplefilter as original_simplefilter
)

def ignore_filterwarnings(*args, **kwargs):
pass

def ignore_simplefilter(*args, **kwargs):
pass

warnings.filterwarnings = ignore_filterwarnings
warnings.simplefilter = ignore_simplefilter

# no imports of sklearn should occur before the previous two lines (otherwise sklearn
# will get to use the original functions).

with warnings.catch_warnings():
original_simplefilter("ignore") # or "error" to see the difference

from my_main_module import main
main()






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 24 '18 at 1:09









DunesDunes

25k44869




25k44869













  • Thank you for the reply. I think that I need to investigate further into the code that I am working with. When I run it on my personal computer on a sample of data, I get the desired output. However, when I run it on the remote computer that houses a larger dataset I am using, I get the Deprication Warning and then the program closes with no indication as to why. I silenced the warnings by adding the shebang '#!/usr/bin/env python -W ignore::DeprecationWarning' to see if anything else could be discovered. I will definitely try your code to see if I can catch anything.

    – Dave L
    Nov 24 '18 at 4:08











  • You might have a version mismatch. It looks like the deprecation warning was fixed as part of 0.20.0, so if you see it on one machine and not another then it would safe to assume the machines have different setups. You should probably investigate how versions of your local and remote machines differ.

    – Dunes
    Nov 24 '18 at 13:53













  • My personal machine has python 3.6, so that is why I thought that I might need to roll back the version of python on the other machine or update my packages. But I will certainly investigate this. Thank you very much for your help.

    – Dave L
    Nov 24 '18 at 14:25



















  • Thank you for the reply. I think that I need to investigate further into the code that I am working with. When I run it on my personal computer on a sample of data, I get the desired output. However, when I run it on the remote computer that houses a larger dataset I am using, I get the Deprication Warning and then the program closes with no indication as to why. I silenced the warnings by adding the shebang '#!/usr/bin/env python -W ignore::DeprecationWarning' to see if anything else could be discovered. I will definitely try your code to see if I can catch anything.

    – Dave L
    Nov 24 '18 at 4:08











  • You might have a version mismatch. It looks like the deprecation warning was fixed as part of 0.20.0, so if you see it on one machine and not another then it would safe to assume the machines have different setups. You should probably investigate how versions of your local and remote machines differ.

    – Dunes
    Nov 24 '18 at 13:53













  • My personal machine has python 3.6, so that is why I thought that I might need to roll back the version of python on the other machine or update my packages. But I will certainly investigate this. Thank you very much for your help.

    – Dave L
    Nov 24 '18 at 14:25

















Thank you for the reply. I think that I need to investigate further into the code that I am working with. When I run it on my personal computer on a sample of data, I get the desired output. However, when I run it on the remote computer that houses a larger dataset I am using, I get the Deprication Warning and then the program closes with no indication as to why. I silenced the warnings by adding the shebang '#!/usr/bin/env python -W ignore::DeprecationWarning' to see if anything else could be discovered. I will definitely try your code to see if I can catch anything.

– Dave L
Nov 24 '18 at 4:08





Thank you for the reply. I think that I need to investigate further into the code that I am working with. When I run it on my personal computer on a sample of data, I get the desired output. However, when I run it on the remote computer that houses a larger dataset I am using, I get the Deprication Warning and then the program closes with no indication as to why. I silenced the warnings by adding the shebang '#!/usr/bin/env python -W ignore::DeprecationWarning' to see if anything else could be discovered. I will definitely try your code to see if I can catch anything.

– Dave L
Nov 24 '18 at 4:08













You might have a version mismatch. It looks like the deprecation warning was fixed as part of 0.20.0, so if you see it on one machine and not another then it would safe to assume the machines have different setups. You should probably investigate how versions of your local and remote machines differ.

– Dunes
Nov 24 '18 at 13:53







You might have a version mismatch. It looks like the deprecation warning was fixed as part of 0.20.0, so if you see it on one machine and not another then it would safe to assume the machines have different setups. You should probably investigate how versions of your local and remote machines differ.

– Dunes
Nov 24 '18 at 13:53















My personal machine has python 3.6, so that is why I thought that I might need to roll back the version of python on the other machine or update my packages. But I will certainly investigate this. Thank you very much for your help.

– Dave L
Nov 24 '18 at 14:25





My personal machine has python 3.6, so that is why I thought that I might need to roll back the version of python on the other machine or update my packages. But I will certainly investigate this. Thank you very much for your help.

– Dave L
Nov 24 '18 at 14:25




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53453959%2fwhy-is-this-deprication-warning-halting-code-execution%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Xamarin.form Move up view when keyboard appear

Post-Redirect-Get with Spring WebFlux and Thymeleaf

Anylogic : not able to use stopDelay()