0

I'm pretty new to packaging scripts and I have an issue understanding how to run my code after converting it to a package! I've developed a script with proper files and functions and used the setup tools to convert it to a package. Suppose a simple module named "Simulation_Package" with __ main_ _.py as:

def main():
    print("running the simulations")
    do stuff 
if __name__ == "__main__":
    main()  

I installed the package in an Anaconda environment and when I use the Anaconda powershell prompt, I can run my script with no issues using:

python Simulation_Package

and it automatically runs my module and gets me the outputs which in this case prints "running the simulations"

When I use Spyder as an IDE, while I can import the package and Spyder recognizes my package, I cannot run the script. I have no idea how to run it actually. Call the main also returns an error:

import Simulation_Package
Simulation_Package.main()

AttributeError: module 'Simulation_Package' has no attribute 'main'

Any idea how to run the code in Spyder?

Seji
  • 371
  • 1
  • 10

1 Answers1

0

Try using pip rather than conda. I suggest you to use pip for packages, conda sometimes behaves abnormally

  • 1
    I installed the package using Pip... I am referring to post-installation issue, reading the package in an IDE – Seji Apr 11 '23 at 23:06