Python Forum
ModuleNotFoundError: No module named 'scipy.optimize'; 'scipy' is not a package
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ModuleNotFoundError: No module named 'scipy.optimize'; 'scipy' is not a package
#1
Quick disclaimer: I'm still very much a beginner to python

I get the error in the title when I run

from scipy.optimize import brentq
Everything I've found regarding this issue suggests that I either do not have scipy installed (I do have it installed though) or have it installed incorrectly. Running a "pip install scipy" gives the following output:

Requirement already satisfied: scipy in c:\users\Aaron\appdata\local\programs\python\python38-32\lib\site-packages (1.5.1)
Requirement already satisfied: numpy>=1.14.5 in c:\users\Aaron\appdata\local\programs\python\python38-32\lib\site-packages (from scipy) (1.18.5)

I also found something saying that the interpreter I'm using may be the problem but it appears to be correct. The interpreter selected is:

Python 3.8 (Python Practice) C:\Users\Aaron\PycharmProjects\Python Practice\venv\Scripts\python.exe

I've successfully imported and used pylab as well as numpy so I'm not sure why scipy is being fussy. Also I'm using the PyCharm IDE if that is pertinent. Some help resolving this issue would be greatly appreciated.
Reply
#2
You probably have a file called "scipy.py" in your PYTHONPATH (such as the current directory). It is overriding the interpreter's search for the actual scipy package.

Rename the file so it doesn't conflict.

Output:
$ python -c 'from scipy.optimize import brentq; print("ok")' ok $ touch scipy.py $ python -c 'from scipy.optimize import brentq; print("ok")' Traceback (most recent call last): File "<string>", line 1, in <module> ModuleNotFoundError: No module named 'scipy.optimize'; 'scipy' is not a package
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Optimize a game of life (4 sec for python when 6 ms for C version !) fatango 0 84 Jan-06-2021, 09:13 PM
Last Post: fatango
  ModuleNotFoundError: No module named 'com' aleksg 9 351 Dec-14-2020, 05:00 PM
Last Post: Larz60+
Video ModuleNotFoundError: No module named ‘…’ Frank911 1 290 Dec-11-2020, 03:59 PM
Last Post: michael1789
  no module named finbert found ErnestTBass 4 276 Dec-05-2020, 06:09 PM
Last Post: andrianas
  ModuleNotFoundError: No module named 'fcntl' ErnestTBass 2 505 Dec-05-2020, 02:39 PM
Last Post: ErnestTBass
  ImportError: No module named coltson 3 307 Nov-21-2020, 10:22 AM
Last Post: Superjoe
  ModuleNotFoundError: No module named 'pyrlang.gen_server' Maxximiliann 0 171 Nov-19-2020, 01:15 AM
Last Post: Maxximiliann
  How to use scipy.optimization.brute for multivariable function Shiladitya 9 483 Oct-28-2020, 10:40 PM
Last Post: scidam
  ModuleNotFoundError: No module named 'requests' Martin 2 470 Oct-04-2020, 03:35 PM
Last Post: Martin
  My Python Console doesn´t work ModuleNotFoundError: No module named 'tokenize' RuanKishibe 1 488 Aug-06-2020, 10:07 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020