Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • pystata not recognized in Jupyter Notebook

    I just upgraded to Stata 17 SE and am trying to import Stata to Jupyter Notebook for the first time. I am receiving an error that "No module named 'stata_setup.'" I have checked that my Anaconda is updated as well. How might I solve this issue?

    I am using the method suggested at: https://www.stata.com/stata-news/new...yter-notebook/

    I first get the following in Stata:

    Code:
    . display(c(sysdir_stata)) C:\Program Files\Stata17/
    Code I am putting in my Python 3 Jupyter Notebook (I have also tried taking out the 'C:' as noted in the following Topic: https://www.statalist.org/forums/for...alling-pystata)
    Code:
    import stata_setup stata_setup.config('C:/Program Files/Stata17/', 'se')
    Error Returned:

    --------------------------------------------------------------------------- ModuleNotFoundError Traceback (most recent call last) <ipython-input-6-a76bcd0c1ed4> in <module> ----> 1 import stata_setup 2 stata_setup.config('/Program Files/Stata17/', 'se') ModuleNotFoundError: No module named 'stata_setup'

  • #2
    Have you installed -pip install pystata- in your activated environment?

    correction: from anaconda promt:

    conda create --name pystata2 python=3.9
    conda activate pystata2
    conda install pandas numpy jupyterlab
    pip install --upgrade --user stata_setup
    Last edited by Bjarte Aagnes; 17 Jun 2021, 10:22.

    Comment


    • #3
      Just tried this, getting the following:

      ERROR: Could not find a version that satisfies the requirement pystata (from versions: none)
      ERROR: No matching distribution found for pystata

      Checked -pip list- and see that the versions of the requirements here (https://www.stata.com/python/pystata...l#requirements) are met

      numpy 1.18.5 (req 1.9)
      pandas 1.0.5 (req 0.15)
      ipython 7.16.1 (req 5.0)

      Comment


      • #4
        see correction in #2 ref https://www.stata.com/python/pystata...alling-via-pip

        Comment


        • #5
          Originally posted by Bjarte Aagnes View Post
          Okay, great! All of that worked, but I am still getting the 'No module named 'stata_setup' even after restarting the kernel. Thanks so much for your help!

          Comment


          • #6
            Hi Dorothy Dickmann,

            If stata_setup was installed successfully, it should be located in Lib\site-packages of your anaconda home directory or if you created a virtual environment, it should be in Lib\site-packages of your virtual environment directory. It is a file named stata_setup.py.

            If it is in your default anaconda environment, you can open a Windows Command Prompt, type

            Code:
            > conda activate 
            > python
            to enter into Python, then type

            Code:
            >>> import stata_setup
            >>> stata_setup.__version__
            to see whether it is there.

            Comment


            • #7
              Zhao Xu (StataCorp) Thank you for the response. I checked using the code you provided -- it had not installed. I repreated the pip install from #2 above, then checked again according to your guidance, and now all is working.

              Bjarte Aagnes Zhao Xu (StataCorp) Thank you both for your assistance!

              Comment

              Working...
              X