1

screenshot of my pycharm interface

Hey everyone. When I run this simple code (the tab 'youtubeyf.py is to print 'hello world'), it produces the intended result but also another script (with the tab name "yfinance.py") result as well. In fact, the "yfinance.py" script doesn't need to be open in order for that result to appear too. It is almost as if it runs in the background, parallel without being open.

Goal: I want to run "print 'hello world'" without the dataframe from the other script appearing.

Problem: the dataframe is appearing without actually running or being open.

Troubleshoot attempts so far: I have "Alphabetted" and searched on StackOverflow, JetBrains on topics regarding reconfiguring the "run configurations", "parallels", and nothing yet.

Thank you for your time.

Edit 1: this does not solve my problem. for one, my issue isn't importing. in fact, everything is "running" smoothly, but that the results are two in one. It is analogous to two chefs preparing one meal each, say shrimp lo main and pizza, and then placing both meals onto one plate. I don't want that; I want to have shrimp lo main on Tuesday night, and then pizza Wednesday.

Jabuc15
  • 13
  • 3
  • Does this answer your question? [Why is Python running my module when I import it, and how do I stop it?](https://stackoverflow.com/questions/6523791/why-is-python-running-my-module-when-i-import-it-and-how-do-i-stop-it) – Maurice Meyer Mar 27 '20 at 21:49

1 Answers1

0

When importing yfinance, it could be possible that in that module, your code is structured such that when you import the module it runs a function or other code. In yfinance, you should delete any extraneous function that doesnt need to be run everytime you import yfinance somewhere else.

Edit: what you can do, if you dont want to change much of the structure yfinance.py, is wrap all the code that runs in that python file inside a main function and add the following:

if __name__=="__main__": main() This makes it so that python only runs main if you're actually running yfinance.py , and doesnt run main when you're importing it.

Michael Ilie
  • 449
  • 2
  • 16