Skip to content
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

ModuleNotFoundError: No module named 'sympy' #4716

Closed
4 tasks done
abigailhaddad opened this issue Mar 9, 2023 · 34 comments
Closed
4 tasks done

ModuleNotFoundError: No module named 'sympy' #4716

abigailhaddad opened this issue Mar 9, 2023 · 34 comments
Assignees
Labels
python-setup Issues with Python's environment and setup windows
Milestone

Comments

@abigailhaddad
Copy link

Bug description

This is the code -- full qmd below

#| echo: true

from sympy.solvers.diophantine.diophantine import diop_solve
from sympy import symbols

This is the error message:

ModuleNotFoundError: No module named 'sympy'

Sympy is installed in my virtual environment. When I start Python from my virtual environment and I run the code snippet, it runs.

I have tried doing !pip install sympy and !pip3 install sympy from within the code snipped and it runs but does not change the error message.

Whether I try to render as a docx, PDF, or word document does not change the outcome.

This is the full QMD that gets me the error message. I have also tried adding pip install sympy and pip3 install sympy from the code snippet and it runs but does not affect the error message


title: "Solving A Linear Equation Two Ways In Python"
author: "Abigail Haddad"
date: "March 08, 2023"

#| echo: true
from sympy.solvers.diophantine.diophantine import diop_solve
from sympy import symbols

I am running this on Windows from a virtual environment. I am not using RStudio.

Checklist

  • Please include a minimal, fully reproducible example in a single .qmd file? Please provide the whole file rather than the snippet you believe is causing the issue.
  • Please format your issue so it is easier for us to read the bug report.
  • Please document the RStudio IDE version you're running (if applicable), by providing the value displayed in the "About RStudio" main menu dialog?
  • Please document the operating system you're running. If on Linux, please provide the specific distribution.
@abigailhaddad abigailhaddad added the bug Something isn't working label Mar 9, 2023
@abigailhaddad
Copy link
Author

I resolved this by running the following from Python:

import sys
paths=[i for i in sys.path]

and then copying the paths as a list into my qmd and adding:

import sys

for path in paths:
sys.path.append(path)

so then it knew where to look for the package

@cscheid
Copy link
Collaborator

cscheid commented Mar 9, 2023

I'm glad that solved the problem for you, but it means that your setup from Python is not the same as what we're seeing. It's probably a good idea to check the version you're getting from quarto check.

@cscheid cscheid added the python-setup Issues with Python's environment and setup label Mar 9, 2023
@abigailhaddad
Copy link
Author

Thanks. This is my output.

(venv) (base) C:\Users\abiga\OneDrive\Documents\PythonScripts\linear_equations\qmd>quarto check

[>] Checking Quarto installation......OK
Version: 1.2.335
Path: C:\Users\abiga\AppData\Local\Programs\Quarto\bin
CodePage: 1252

[>] Checking basic markdown render....OK

[>] Checking Python 3 installation....OK
Version: 3.9.13 (Conda)
Path: C:/Users/abiga/anaconda3/python.exe
Jupyter: 4.11.1
Kernels: python3

[>] Checking Jupyter engine render....OK

[>] Checking R installation...........OK
Version: 4.2.2
Path: C:/PROGRA1/R/R-421.2
LibPaths:
- C:/Users/abiga/AppData/Local/R/win-library/4.2
- C:/Program Files/R/R-4.2.2/library
rmarkdown: 2.20

@abigailhaddad
Copy link
Author

My setup is pretty bad right now in terms of having multiple versions of Python installed. It was my hope that by using a virtual environment that would not matter.

@cscheid
Copy link
Collaborator

cscheid commented Mar 9, 2023

[>] Checking Python 3 installation....OK
Version: 3.9.13 (Conda)
Path: C:/Users/abiga/anaconda3/python.exe
Jupyter: 4.11.1
Kernels: python3

Two things:

  1. 4.11.1 is a fairly old version of Jupyter; I think we technically support it, but I wouldn't be surprised if things go bad.

  2. Now compare C:/Users/abiga/anaconda3/python.exe to what you get if you run Python "as usual" (like you did when you said "I resolved this by running the following from Python:"), but run this instead:

    import sys
    print(sys.executable)

I suspect you'll see different results. If that's the case, then what you need to do, then, is remove C:/Users/abiga/anaconda3/python.exe from your PATH, so that the "good" version of Python is the one we see.

It was my hope that by using a virtual environment that would not matter.

This is actually true, but you need to make sure that the virtual environment is active before running quarto (we have no way to see which virtual environment you mean, and we use whatever the shell tells us)

@abigailhaddad
Copy link
Author

Thank you.

  1. I ran pip install notebook --upgrade and pip install notebook==6.5.3, but I'm getting the same output from quarto check in terms of the Jupyter version. I tried this inside and outside the virtual environment with no difference. The current version of Jupyter is there, it's just not what quarto is finding. Maybe this is because I'm pip installing it, but I'm running this from Anaconda prompt and says it's using a Conda version.

  2. Unfortunately, it's the same: C:\Users\abiga\anaconda3\python.exe

sys

@abigailhaddad
Copy link
Author

  1. I uninstalled all the versions of Python.
  2. Uninstalled Anaconda.
  3. Installed Python via python.org downloads
  4. pip installed jupyter
  5. Now this is what I get:
    C:\Users\abiga>quarto check

[>] Checking Quarto installation......OK
Version: 1.2.335
Path: C:\Users\abiga\AppData\Local\Programs\Quarto\bin
CodePage: 1252

[>] Checking basic markdown render....OK

[>] Checking Python 3 installation....OK
Version: 3.11.2
Path: C:/Users/abiga/AppData/Local/Programs/Python/Python311/python.exe
Jupyter: 5.2.0
Kernels: python3

() Checking Jupyter engine render....0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
2023-03-09 00:11:00,153 - traitlets - ERROR - Failed to run command:
['C:\Users\abiga\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\python.exe', '-m', 'ipykernel_launcher', '-f', 'C:\Users\abiga\AppData\Local\Temp\tmpepux18wb.json', '--HistoryManager.hist_file=:memory:']
PATH='C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\dotnet\;C:\Program Files\Git\cmd;C:\Program Files\nodejs\;C:\ProgramData\chocolatey\bin;C:\Users\abiga\AppData\Local\Programs\Python\Python311;C:\Users\abiga\AppData\Local\Programs\Python\Python311\Scripts;C:\Users\abiga\AppData\Local\Programs\Quarto\bin;"C:\Users\abiga\AppData\Local\Microsoft\WindowsApps; C:\\Users\\abiga\\anaconda3";C:\Users\abiga\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Spyder\Python;C:\Users\abiga\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\abiga\AppData\Roaming\npm;'
with kwargs:
{'stdin': -1, 'stdout': None, 'stderr': None, 'cwd': 'C:\Users\abiga\AppData\Local\Temp\quarto-session056b62d8\b5433307', 'close_fds': False}

2023-03-09 00:11:00,153 - traitlets - ERROR - [WinError 2] The system cannot find the file specified
Traceback (most recent call last):
File "C:\Users\abiga\AppData\Local\Programs\Python\Python311\Lib\site-packages\jupyter_client\manager.py", line 82, in wrapper
out = await method(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\abiga\AppData\Local\Programs\Python\Python311\Lib\site-packages\jupyter_client\manager.py", line 395, in _async_start_kernel
await ensure_async(self._launch_kernel(kernel_cmd, **kw))
File "C:\Users\abiga\AppData\Local\Programs\Python\Python311\Lib\site-packages\jupyter_client\utils.py", line 38, in ensure_async
return await obj
^^^^^^^^^
File "C:\Users\abiga\AppData\Local\Programs\Python\Python311\Lib\site-packages\jupyter_client\manager.py", line 311, in _async_launch_kernel
connection_info = await self.provisioner.launch_kernel(kernel_cmd, **kw)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\abiga\AppData\Local\Programs\Python\Python311\Lib\site-packages\jupyter_client\provisioning\local_provisioner.py", line 204, in launch_kernel
self.process = launch_kernel(cmd, **scrubbed_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\abiga\AppData\Local\Programs\Python\Python311\Lib\site-packages\jupyter_client\launcher.py", line 170, in launch_kernel
raise ex
File "C:\Users\abiga\AppData\Local\Programs\Python\Python311\Lib\site-packages\jupyter_client\launcher.py", line 158, in launch_kernel
proc = Popen(cmd, **kwargs)
^^^^^^^^^^^^^^^^^^^^
File "C:\Users\abiga\AppData\Local\Programs\Python\Python311\Lib\subprocess.py", line 1024, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\abiga\AppData\Local\Programs\Python\Python311\Lib\subprocess.py", line 1493, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [WinError 2] The system cannot find the file specified

[WinError 2] The system cannot find the file specified
[>] Checking Jupyter engine render....OK

@cscheid
Copy link
Collaborator

cscheid commented Mar 9, 2023

@cderv Do you have experience with Python installs on windows that might be able to help here?

@cscheid cscheid removed the bug Something isn't working label Mar 9, 2023
@cderv
Copy link
Collaborator

cderv commented Mar 9, 2023

ouch this seems to be a nasty bug somewhere... I have some solutions on how to manage environment but first, if you agree I would like to understand better your setup.

From the log you shared, it seems related to Windows python.exe defaulting to installing a python from Windows Store (don't know why they did that really). But s you installed a python version from Python.prg I am surprised it is not using that, and that we see this one in log

C:\Users\abiga\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\python.exe

Did you select add to PATH when running the installer ?

First question: Do you know install python from the windows store ? If you don't know, you can probably check from the windows store, or we'll know from the following.

To confirm this, can you run for me in a Powershell terminal

  • winget list -q python if you are on a recent enough windows which has winget
  • gcm python and gcm python3
  • py -0p (as you should have the python launcher for windows) available.

You can do that from a normal terminal, and one with the virtualenv you want to use, if any.

Checking the PATH could also get us some hint on what is available

$env:PATH -Split ";"

Thanks

@abigailhaddad
Copy link
Author

abigailhaddad commented Mar 9, 2023

Thanks.

  1. I did not install Python from the windows store, I went directly to Python.org
  2. I added it to path manually.
  3. Output:
    winget list -q python
Name                   Id                                     Version
-------------------------------------------------------------------------
Python Launcher        {C28EE783-FA9C-4E09-910E-181A4A28C29C} 3.11.2150.0
Python 3.11.2 (64-bit) {4d5f29cf-3d3f-455f-bd47-5a52fb830b25} 3.11.2150.0

**gcm python**
CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Application     python.exe                                         3.11.21... C:\Users\abiga\AppData\Local\Programs\...

**gcm python3**

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Application     python3.exe                                        0.0.0.0    C:\Users\abiga\AppData\Local\Microsoft...

So that's different!

py -0p

 -V:3.11 *        C:\Users\abiga\AppData\Local\Programs\Python\Python311\python.exe

this is path:

PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\dotnet\;C:\Program Files\Git\cmd;C:\Program Files\nodejs\;C:\ProgramData\chocolatey\bin;C:\Users\abiga\AppData\Local\Programs\Python\Python311;C:\Users\abiga\AppData\Local\Programs\Python\Python311\Scripts;C:\WINDOWS\System32;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\wbem;C:Windows\System32;C:\Users\abiga\AppData\Local\Programs\Quarto\bin;"C:\Users\abiga\AppData\Local\Microsoft\WindowsApps; C:\\Users\\abiga\\anaconda3";C:\Users\abiga\AppData\Local\Microsoft\WindowsApps;C:\Users\abiga\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\abiga\AppData\Roaming\npm;

@abigailhaddad
Copy link
Author

  1. uninstalled Python.
  2. installed it from the windows store.
  3. sys.executable is now 'C:\Users\abiga\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\python.exe'
  4. made the QUARTO_PYTHON environmental variable equal to that (tried with \s or ).
  5. C:\Users\abiga>quarto check

[>] Checking Quarto installation......OK
Version: 1.2.335
Path: C:\Users\abiga\AppData\Local\Programs\Quarto\bin
CodePage: 1252

[>] Checking basic markdown render....OK

ERROR: The file cannot be accessed by the system. (os error 1920), stat 'C:\Users\abiga\AppData\Local\Microsoft\WindowsApps\python.exe'

When I take that out of my environmental variable I instead get:

Unable to locate an installed version of Python 3.
Install Python 3 from https://www.python.org/downloads/

@cscheid
Copy link
Collaborator

cscheid commented Mar 9, 2023

(I'm just adding some additional information to make @cderv's job easier when he sees this)

Inspecting the difference between

C:\Users\abiga\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\python.exe

and

ERROR: The file cannot be accessed by the system. (os error 1920), stat 'C:\Users\abiga\AppData\Local\Microsoft\WindowsApps\python.exe'

Makes me think that something, somewhere, is getting confused about subdirectories, and that long PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0 entry is immediately suspicious to me.

The only place where we check for QUARTO_PYTHON is in getQuartoJupyterCapabilities in src/core/jupyter/capabilities.ts, but I don't know how we could possibly be dropping that last directory.

isAbsolute() should return true for this value, and so should existsSync(). Then, the condition in line 107 should test false, which means we should be passing the entire file to getJupyterCapabilities in line 119. But clearly we're not. I don't understand how this is possible..

@cderv cderv added this to the v1.4 milestone Mar 10, 2023
@cderv cderv added the windows label Mar 10, 2023
@cderv
Copy link
Collaborator

cderv commented Mar 10, 2023

Thanks @abigailhaddad and @cscheid !

@abigailhaddad sorry for not having thought about that, but the path is of interest in gcm call and we can't see it in output. Can you repost with

gcm python3 | Format-List -Property Name, Definition, Path
gcm python | Format-List -Property Name, Definition, Path

I believe the issue we encounter here is with python3.exe which is still pointing to microsoft store weird alias.

Some context about Microsoft store version

  • I find that the windows store python version is not good to use. They offer a windows way to made it simple but I don't think it is when you want to control your environment.
    • Windows store will update your version automatically
    • It will be added among Windows store app
    • We had some issues with some tools in the past (R reticulate package).

Personally, I would not use this version. Your installed python.org versions seemed ok. py -0p was finding it, and we use py.exe for finding the right python version. It seems it should have worked for you in #4716 (comment) but for some reason python3.exe seemed to point to windows store version.

One thing that could mess things up is the Windows alias that are supposed to be helping user; If you don't have Python installed, python.exe and python3.exe are aliases that will open Windows Store to install Python. Thoses aliases should be hidden if the installed python (from python.org) is correctly set in PATH to hide the aliases. This is really messed up IMO and so usually my advice is to deactivate those aliases. More on Windows FAQ Why does running python.exe open the Microsoft Store?

So you could also try this

  • Come clean and uninstalled Python from windows store
  • Deactivate the alias
  • Install from python.org

Quarto should find Python correctly.

For 1.4, I'll definitely try to check all those scenarios to check we handle correctly - I am under the impression that the Windows Store version python does not work well with Quarto.

that long PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0 entry is immediately suspicious to me.

This is the folder name that Windows App installed get usually so not unusual but maybe our code does not handle correctly. 🤔
I need to setup from scratch somewhere to check.

@abigailhaddad
Copy link
Author

abigailhaddad commented Mar 10, 2023

  1. I uninstalled windows-Python and installed it from downloads.
  2. Took AppData out of my Path. C:\Users\abiga\AppData\Local\Programs\Python\Python311\ is now the first thing in Path
  3. Disabled aliases
$ gcm python | Format-List -Property Name, Definition, Path

Name       : python.exe
Definition : C:\\Users\\abiga\\AppData\\Local\\Programs\\Python\\Python311\python.exe
Path       : C:\\Users\\abiga\\AppData\\Local\\Programs\\Python\\Python311\python.exe

$ gcm python3 | Format-List -Property Name, Definition, Path
gcm : The term 'python3' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ gcm python3 | Format-List -Property Name, Definition, Path
+ ~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (python3:String) [Get-Command], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Commands.GetCommandCommand

4. quarto check

PS C:\Users\abiga> quarto check

[>] Checking Quarto installation......OK
      Version: 1.2.335
      Path: C:\Users\abiga\AppData\Local\Programs\Quarto\bin
      CodePage: 1252

[>] Checking basic markdown render....OK

[>] Checking Python 3 installation....OK
      Version: 3.11.2
      Path: C:/Users/abiga/AppData/Local/Programs/Python/Python311/python.exe
      Jupyter: 5.2.0
      Kernels: python3

(/) Checking Jupyter engine render....0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
2023-03-10 15:58:42,800 - traitlets - ERROR - Failed to run command:
['C:\\Users\\abiga\\AppData\\Local\\Microsoft\\WindowsApps\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\python.exe', '-m', 'ipykernel_launcher', '-f', 'C:\\Users\\abiga\\AppData\\Local\\Temp\\tmp1lwjbr6c.json', '--HistoryManager.hist_file=:memory:']
    PATH='C:\\\\Users\\\\abiga\\\\AppData\\\\Local\\\\Programs\\\\Python\\\\Python311;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\WINDOWS\\System32\\OpenSSH\\;C:\\Program Files\\dotnet\\;C:\\Program Files\\Git\\cmd;C:\\Program Files\\nodejs\\;C:\\ProgramData\\chocolatey\\bin;C:\\WINDOWS\\System32;C:Windows\\System32;C:\\Users\\abiga\\AppData\\Local\\Programs\\Quarto\\bin;C:\\Users\\abiga\\AppData\\Local\\Programs\\Microsoft VS Code\\bin;C:\\Users\\abiga\\AppData\\Roaming\\npm;'
    with kwargs:
{'stdin': -1, 'stdout': None, 'stderr': None, 'cwd': 'C:\\Users\\abiga\\AppData\\Local\\Temp\\quarto-sessiondb7cfb6d\\7b08a561', 'close_fds': False}

2023-03-10 15:58:42,800 - traitlets - ERROR - [WinError 2] The system cannot find the file specified
Traceback (most recent call last):
  File "C:\Users\abiga\AppData\Local\Programs\Python\Python311\Lib\site-packages\jupyter_client\manager.py", line 82, in wrapper
    out = await method(self, *args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\abiga\AppData\Local\Programs\Python\Python311\Lib\site-packages\jupyter_client\manager.py", line 395, in _async_start_kernel
    await ensure_async(self._launch_kernel(kernel_cmd, **kw))
  File "C:\Users\abiga\AppData\Local\Programs\Python\Python311\Lib\site-packages\jupyter_client\utils.py", line 38, in ensure_async
    return await obj
           ^^^^^^^^^
  File "C:\Users\abiga\AppData\Local\Programs\Python\Python311\Lib\site-packages\jupyter_client\manager.py", line 311, in _async_launch_kernel
    connection_info = await self.provisioner.launch_kernel(kernel_cmd, **kw)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\abiga\AppData\Local\Programs\Python\Python311\Lib\site-packages\jupyter_client\provisioning\local_provisioner.py", line 204, in launch_kernel
    self.process = launch_kernel(cmd, **scrubbed_kwargs)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\abiga\AppData\Local\Programs\Python\Python311\Lib\site-packages\jupyter_client\launcher.py", line 170, in launch_kernel
    raise ex
  File "C:\Users\abiga\AppData\Local\Programs\Python\Python311\Lib\site-packages\jupyter_client\launcher.py", line 158, in launch_kernel
    proc = Popen(cmd, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\abiga\AppData\Local\Programs\Python\Python311\Lib\subprocess.py", line 1024, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\abiga\AppData\Local\Programs\Python\Python311\Lib\subprocess.py", line 1493, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [WinError 2] The system cannot find the file specified


[WinError 2] The system cannot find the file specified
[>] Checking Jupyter engine render....OK

@abigailhaddad
Copy link
Author

abigailhaddad commented Mar 11, 2023

I copied my python.exe file to where it was looking for a python.exe file
C:\Users\abiga\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\python.exe

I now get this:

 Checking Quarto installation......OK
      Version: 1.2.335
      Path: C:\Users\abiga\AppData\Local\Programs\Quarto\bin
      CodePage: 1252

[>] Checking basic markdown render....OK

[>] Checking Python 3 installation....OK
      Version: 3.11.2
      Path: C:/Users/abiga/AppData/Local/Programs/Python/Python311/python.exe
      Jupyter: 5.2.0
      Kernels: python3

(|) Checking Jupyter engine render....0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.02s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
[>] Checking Jupyter engine render....OK

[>] Checking R installation...........OK
      Version: 4.2.2
      Path: C:/PROGRA~1/R/R-42~1.2
      LibPaths:
        - C:/Users/abiga/AppData/Local/R/win-library/4.2
        - C:/Program Files/R/R-4.2.2/library
      rmarkdown: 2.20

[>] Checking Knitr engine render......OK

But then when I run quarto, it can't find any of my libraries, because the executable it's now using is C:\\Users\\abiga\\AppData\\Local\\Microsoft\\WindowsApps\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\python.exe

which I can tell because I made a qmd file that just prints out where the executable is:

import sys
print(sys.executable) 

C:\Users\abiga\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.10_qbz5n2k

@cderv
Copy link
Collaborator

cderv commented Mar 13, 2023

First, I took the liberty to reformat your code as code so that it is easier to read.

  • gcm python shows that it is found
  • gcm python3 shows that it is not available, and so only python.exe is available. Which seems ok with recent Python.
  • quarto check found the the correct python.exe at Path: C:/Users/abiga/AppData/Local/Programs/Python/Python311/python.exe

Now I don't understand why 'C:\\Users\\abiga\\AppData\\Local\\Microsoft\\WindowsApps\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\python.exe is still used when Jupyter is run, especially if not existing. Possibly an old configuration problem.

I copied my python.exe file to where it was looking for a python.exe file

Not a good solution to do that, usually executable file are expecting resource to be relative to the exe file, so that is why it doesn't work after. Even if it worked, I wouldn't trust the setup.

I think your close to debug your setup - we need to check configuration
Can you check your Jupyter kernel configuration?

jupyter kernelspec list

Should show which python3 is used . Thanks

Also I don't think having python.exe only is an issue - it is at least a known weirdness of Windows install through python.org

it is just that python.exe should be called and not python3.exe but quarto does find the right exe. I wonder if Jupyter is correctly configured. You could also uninstall and reinstall Jupyter in your new Python install after all you've done.

@abigailhaddad
Copy link
Author

Thank you.

  1. Copying the executables is 'working', in that I can run quarto so long as I hard-code the list of sys.paths and append it within Quarto, but it's definitely not what I want to do.
  2. jupyter kernelspec list
    this isn't getting found (in either CMD or powershell

jupyter : The term 'jupyter' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

'jupyter' is not recognized as an internal or external command,
operable program or batch file.

  1. When I run
    pip install jupyterlab
    it says it's already installed.

  2. When I run
    . pip uninstall jupyterlab, I get the following:
    C:\Users\abiga>pip3 uninstall jupyter
    Found existing installation: jupyter 1.0.0
    Uninstalling jupyter-1.0.0:
    Would remove:
    c:\users\abiga\appdata\local\programs\python\python311\lib\site-packages\jupyter-1.0.0.dist-info*
    c:\users\abiga\appdata\local\programs\python\python311\lib\site-packages\jupyter.py

I looked for where a jupyter.exe file might be and I found various .exe files which begin "jupyter" in here: "C:\Users\abiga\AppData\Local\Programs\Python\Python311\Scripts\jupyter-lab.exe", but not one that's just "juypter.exe"

@abigailhaddad
Copy link
Author

Also - potentially unrelated (or at least not fixed in even an ad hoc way by appending sys.paths), I'm having issues with plotly - two separate ones having to do with not writing out figures to .docx or .pdf files (but writing them out to html), and then not being able to save a figure to .png (or other file formats) at all. Should I make another issue for that or assume it might be related to this, or just wait? Thanks.

@cderv
Copy link
Collaborator

cderv commented Mar 13, 2023

Copying the executables is 'working', in that I can run quarto so long as I hard-code the list of sys.paths and append it within Quarto, but it's definitely not what I want to do.

This is definitely a configuration issue. Something in your Python configuration is messing up the path, and you manage to make it work by fixing at the higher level within document.

I would try to find this python kernel spec. It is in a kernel.json file somewhere under where Jupyter is installed.

'jupyter' is not recognized as an internal or external command,
operable program or batch file.

This is surprising that is works ok without it. It seems you have jupyter-lab and not jupyter itself.

Regarding jupyter command, it is made available when you install jupyter module - this is the requirement we have in Python install for Quarto https://quarto.org/docs/computations/python.html#installation

The exe should be available has a command as long as you have the Scripts folder in your PATH. The Scripts folder of your Python installation is where usually all the command from Python's module are installed.

This should be part of the setup from your Python installation.

@abigailhaddad
Copy link
Author

  1. The jupyter module is installed. I just ran py -m pip install jupyter, and it did not install anything new, and it did not change the error message I get for jupyter kernelspec list.
  2. When I run pip show jupyter, I get this:
    Name: jupyter
    Version: 1.0.0
    Summary: Jupyter metapackage. Install all the Jupyter components in one go.
    Home-page: http://jupyter.org
    Author: Jupyter Development Team
    Author-email: [email protected]
    License: BSD
    Location: C:\Users\abiga\AppData\Local\Programs\Python\Python311\Lib\site-packages
    Requires: ipykernel, ipywidgets, jupyter-console, nbconvert, notebook, qtconsole
    Required-by:
  3. There is a kernel.json file here: "C:\Users\abiga\AppData\Local\Programs\Python\Python311\share\jupyter\kernels\python3\kernel.json"
  4. Scripts is in my path.

@abigailhaddad
Copy link
Author

It was putting jupyter.exe here: C:\Users\abiga\AppData\Roaming\Python\Python311\Scripts; adding that to my environment

@abigailhaddad
Copy link
Author

Different error message now:

jupyter kernelspec list
Fatal error in launcher: Unable to create process using '"C:\Python311\python.exe" "C:\Users\abiga\AppData\Roaming\Python\Python311\Scripts\jupyter.exe" kernelspec list': The system cannot find the file specified.

@cderv
Copy link
Collaborator

cderv commented Mar 14, 2023

"C:\Users\abiga\AppData\Local\Programs\Python\Python311\share\jupyter\kernels\python3\kernel.json"

This files should contain the info shown usually with kernelspec list - did you look into it ?

Fatal error in launcher: Unable to create process using '"C:\Python311\python.exe"

I don't know why now you have a very short path for installation.

Sorry for all this trouble and (unsucessful) help to debug all this. I am thinking everything gets mixed up maybe after all the tries.
Trying to clean and restart fresh could be the most helpful. Paths issues are the worst...

I am still available to help you as most as I can. The idea behind looking in this kernel.json file was to check which python version is configured with the kernel.

Anyway, regarding Python install, usually our recommended way is

We plan to update this with more information, and also better support Pyenv users.

@cderv
Copy link
Collaborator

cderv commented Mar 31, 2023

@abigailhaddad Is this now ok ?

Can we close this issue ?

@abigailhaddad
Copy link
Author

Thanks. I didn't get it working, but we can close it. At this point, I would just hard-code amending the paths of my libraries to use this.

@allenmanning allenmanning closed this as not planned Won't fix, can't repro, duplicate, stale Apr 3, 2023
@cderv
Copy link
Collaborator

cderv commented Apr 3, 2023

I didn't get it working, but we can close it. At this point, I would just hard-code amending the paths of my libraries to use this.

This does not seem right to me. Please follow #4737 so that we can revisit all this when this is ready. We should really make the experience better - we can't be satisfied by a hard-coded workaround. The experience should be smoother. So please come back to us again with this and see you around in #4737

thanks

@AlexSantopaolo
Copy link

I have the same issue. Do you have further suggestion?

@cderv
Copy link
Collaborator

cderv commented Apr 3, 2023

I have the same issue. Do you have further suggestion?

Which issue ? This thread have several issues found along the investigation, and quite specific to @abigailhaddad set up from what we understood.

@AlexSantopaolo can you open a new issue explaining your setup and what issue you encounter ? Please test with Quarto 1.3

Thank you

@Maripash
Copy link

Maripash commented May 9, 2023

Hi. I'm having the same ModuleNotFoundError: No module named 'sympy' error, even though it's installed. I'm trying to run my code in Visual studio, here are some details:
pip show sympy
Name: sympy
Version: 1.10.1
Summary: Computer algebra system (CAS) in Python
Home-page: https://sympy.org
Author: SymPy development team
Author-email: [email protected]
License: BSD
Location: c:\users\XXX\appdata\local\programs\python\python37\lib\site-packages
Requires: mpmath
Required-by: pydy

and

jupyter kernelspec list
Available kernels:
%s %s python3 C:\Python310\share\jupyter\kernels\python3

@abigailhaddad
Copy link
Author

abigailhaddad commented May 9, 2023 via email

@Maripash
Copy link

Maripash commented May 9, 2023

I never exactly resolved this, but the workaround of adding the locations of my packages - hard-coding those - did work.

On Tue, May 9, 2023, 5:16 AM Maripash @.> wrote: Hi. I'm having the same ModuleNotFoundError: No module named 'sympy' error, even though it's installed. I'm trying to run my code in Visual studio, here are some details: pip show sympy Name: sympy Version: 1.10.1 Summary: Computer algebra system (CAS) in Python Home-page: https://sympy.org Author: SymPy development team Author-email: @. License: BSD Location: c:\users\XXX\appdata\local\programs\python\python37\lib\site-packages Requires: mpmath Required-by: pydy and jupyter kernelspec list Available kernels: %s %s python3 C:\Python310\share\jupyter\kernels\python3 — Reply to this email directly, view it on GitHub <#4716 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AECVNW6QAGJDHNBESNVEL6TXFIDNHANCNFSM6AAAAAAVUNPHJE . You are receiving this because you were mentioned.Message ID: @.***>

I have solved it!
For some reason running this in terminal helped me: py -m pip install sympy

@Maripash
Copy link

Maripash commented May 9, 2023

I never exactly resolved this, but the workaround of adding the locations of my packages - hard-coding those - did work.

On Tue, May 9, 2023, 5:16 AM Maripash @.> wrote: Hi. I'm having the same ModuleNotFoundError: No module named 'sympy' error, even though it's installed. I'm trying to run my code in Visual studio, here are some details: pip show sympy Name: sympy Version: 1.10.1 Summary: Computer algebra system (CAS) in Python Home-page: https://sympy.org Author: SymPy development team Author-email: @. License: BSD Location: c:\users\XXX\appdata\local\programs\python\python37\lib\site-packages Requires: mpmath Required-by: pydy and jupyter kernelspec list Available kernels: %s %s python3 C:\Python310\share\jupyter\kernels\python3 — Reply to this email directly, view it on GitHub <#4716 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AECVNW6QAGJDHNBESNVEL6TXFIDNHANCNFSM6AAAAAAVUNPHJE . You are receiving this because you were mentioned.Message ID: @.***>

I have found an article that suggested to run the following commands, maybe one if them will help you:

pip install sympy

👇️ for Python 3

pip3 install sympy

👇️ if you don't have pip in your PATH environment variable

python -m pip install sympy

👇️ for Python 3

python3 -m pip install sympy

👇️ using py alias

py -m pip install sympy

👇️ if you get permissions error

pip install sympy --user

👇️ for Anaconda

conda install -c anaconda sympy

@abigailhaddad
Copy link
Author

abigailhaddad commented May 9, 2023 via email

@Maripash
Copy link

Maripash commented May 9, 2023

I had SymPy installed, which is why it was working to hard code the locations of the packages - because it was there, it just wasn't getting found. Did you find that installing with py made quarto find the package, even though you'd previously installed it with pip or in some other way?

On Tue, May 9, 2023, 8:16 AM Maripash @.> wrote: I never exactly resolved this, but the workaround of adding the locations of my packages - hard-coding those - did work. … <#m_-1315262881479159798_> On Tue, May 9, 2023, 5:16 AM Maripash @.> wrote: Hi. I'm having the same ModuleNotFoundError: No module named 'sympy' error, even though it's installed. I'm trying to run my code in Visual studio, here are some details: pip show sympy Name: sympy Version: 1.10.1 Summary: Computer algebra system (CAS) in Python Home-page: https://sympy.org https://sympy.org Author: SymPy development team Author-email: @. License: BSD Location: c:\users\XXX\appdata\local\programs\python\python37\lib\site-packages Requires: mpmath Required-by: pydy and jupyter kernelspec list Available kernels: %s %s python3 C:\Python310\share\jupyter\kernels\python3 — Reply to this email directly, view it on GitHub <#4716 (comment) <#4716 (comment)>>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AECVNW6QAGJDHNBESNVEL6TXFIDNHANCNFSM6AAAAAAVUNPHJE . You are receiving this because you were mentioned.Message ID: @.> I have found an article that suggested to run the following commands, maybe one if them will help you: pip install sympy 👇️ for Python 3 pip3 install sympy 👇️ if you don't have pip in your PATH environment variable python -m pip install sympy 👇️ for Python 3 python3 -m pip install sympy 👇️ using py alias py -m pip install sympy 👇️ if you get permissions error pip install sympy --user 👇️ for Anaconda conda install -c anaconda sympy — Reply to this email directly, view it on GitHub <#4716 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AECVNW2TQIVYRWXUOMJKVTTXFIYS3ANCNFSM6AAAAAAVUNPHJE . You are receiving this because you were mentioned.Message ID: @.*>

Yes! I also had my sympy installed, but for some reason when I was trying to run a code, I was having an error saying that it is not installed. So I installed it again using "python3 -m pip install sympy" and it worked. Basically, I've just went through all commands I've send in previous message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
python-setup Issues with Python's environment and setup windows
Projects
None yet
Development

No branches or pull requests

6 participants