question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Conflict python between Spyder, Octave and TensorFlow

See original GitHub issue

Hello, 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. PATHS 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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:18 (11 by maintainers)

github_iconTop GitHub Comments

3reactions
CAM-Gerlachcommented, Jun 10, 2020

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 the PATH. The Octave-Python-related entries in your PATH 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 system PATH 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:

  1. Uninstall the Python 3.8 you installed from the Windows store, and any other stray Pythons on your system
  2. Delete the PYTHONPATH environment variable and the Python38-related PATH entries from Windows control panel
  3. Delete the directories %ProgramFiles%/Python38 and %appdata%/python if they still exist.
  4. Reboot your machine
  5. In Octave, enter the command setenv PYTHON C:/ProgramData/Anaconda3/python.exe to point Symbolic to your Anaconda Python
  6. Start and use Symbolic as you normally would (pkg load symbolic then syms x)

To avoid having to repeat step 5 every time you start Octave, in Control Panel create/set the PYTHON system environment variable to C:\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!

2reactions
juanis2112commented, Jun 10, 2020

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!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Found conflicts when installing Spyder in an environment ...
I'm experiencing dependence conflicts when trying to install spyder in an environment that includes package tensorflow-gpu release 2.5 from ...
Read more >
Error while calling a python program from Octave?
I am using Octave for programing and Python for plotting. To make this process automated, I want to call the python script from...
Read more >
Python environments with Conda
Conda is a popular package manager that is especially popular in data science and machine learning communities.
Read more >
Hammer User Guide ... - ITaP Research Computing - Knowledge Base
ITaP maintains a set of popular machine learning (ML) applications on Hammer. These are Anaconda/Python based distribution of the respective applications.
Read more >
oct2py
'Python to GNU Octave bridge --> run m-files from python.'
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found