Conflict python between Spyder, Octave and TensorFlow
See original GitHub issueHello, I am very new of python environment. After some time spent learning python through Anaconda on Windows PC (in particular with Spyder), I also decided to learn Tensorflow, always in Spyder. So, I created a new dedicated environment for TF with the v3.6.9 and v1.17.2, respectively, for python and numpy.
I have never had problems running codes that require TF import with this configuration. However, after some time, to use the Octave symbolic library I had to download Python from Microsoft Store. The downloaded version were 3.8.3 and I also installed the pip package from cmd. The symbolic package in Octave works, but from that moment when I run a code in Spyder that requires the import of tensorflow, I get the following error:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devd_ocs/user/trou_bleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.6 from "C:\Users\ivang\.conda\envs\tensorflow_cpu\python.exe"
* The NumPy version is: "1.18.4"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: No module named `'numpy.core._multiarray_umath_'
As suggested, checking my PATH and PYTHONPATH environment variables I obtained the paths in the attached picture. These environment variables were not created by me, but by Python at the time of its stand-alone installation.
I understand that the problem is related to the different versions of python installed, but why this conflict happens if I created a dedicated environment in Anaconda, as explained at the beginning of the post? How can I solve this conflict using both TF in Spyder and the library in Octave on the same PC?
I tried to uninstall Python 3.8 but the environment variables remain and also the directory in C:\Program Files\Python38\ where site packages are installed.
Thank you so much for the help, IG
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:18 (11 by maintainers)
Top GitHub Comments
Hey, so this is a pretty tricky issue that us Spyder developers struggle with too. As @juanis2112 explained, Spyder is using your Anaconda Python (as you intend), but then tries to load the Numpy 1.18 installed alongside Octive due to the
PYTHONPATH
, which takes precedence over thePATH
. The Octave-Python-related entries in yourPATH
actually don’t directly contribute to the problem because they are at the end, and the Anaconda entries at the beginning override them (which you don’t see in your systemPATH
variable outside of Spyder since Anaconda adds them dynamically).However, in your case there is a pretty straightforward solution, which I’ve confirmed works with Octave, Symbolic, and Anaconda: Uninstall the Python you installed and just point Symbolic to Anaconda’s own Python and SymPy instead, following Symbolic’s recommended install procedure.
To do this:
PYTHONPATH
environment variable and the Python38-relatedPATH
entries from Windows control panel%ProgramFiles%/Python38
and%appdata%/python
if they still exist.setenv PYTHON C:/ProgramData/Anaconda3/python.exe
to point Symbolic to your Anaconda Pythonpkg load symbolic
thensyms x
)To avoid having to repeat step 5 every time you start Octave, in Control Panel create/set the
PYTHON
system environment variable toC:\ProgramData\Anaconda3\python.exe
(or whatever path worked in Step 5) and reboot your machine, and you’ll be good to go. Thanks, and best of luck!I’m glad you could fix it with what @CAM-Gerlach suggested! @IvanGas Thanks for your kind words. We’re happy to help!
Happy Spydering!