Before you say it: YES!! I have checked the twelve different articles with solutions. None of them worked. Mostly because they were outdated.
I can run tensorflow in command prompt with python just fine, but in vs code it just doesnt work.
This is really annoying.
I tried to install older versions and that did not work either. I also tried uninstalling and reinstalling tensorflow, which didnt work.
EDIT:
VS CODE SYSTEM PATH:
COMMAND LINE PATHS:
Related
Currently on windows 10, using VSCode to run python.
So I recently downloaded python3.8 when I was using python 3.7. Everything was working fine when I was still on python3.7. I now have multiple python directories and I think my imported libraries are throwing errors because of it.
I now have python in(these are results from searching python and right clicking -> open file location) :
C:\Python38
C:\Users\david\AppData\Roaming\Python\Python38
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Python 3.8
C:\Users\david\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Python 3.7
As for installed programs I have :
python3.8.5(64-bit)
Python launcher
Should I add all four paths to my environment...?
Frankly I don't even know anymore how to tackle this problem. I'm not even sure what the problem is I just think its a problem. If someone could link me another stackoverflow or help that would be great.
If this isn't supposed to be a problem then I guess I have some more googling to do...
Thank you
EDIT(commented below): One specific error I keep on getting is when I install keras and tensorflow, and run a program, it keeps on asking me to install tensorflow 2.2.0 even though I've already installed it. I have C:\Python38 and C:\Users\david\AppData\Roaming\Python\Python38 in my windows path and C:\Python38 as my VSCode path –
I'm having a problem with importing modules in python.
When I run my program in the command line it works perfectly fine.
However, when I try to run the same program in the python shell I am prompted with the following error:
ModuleNotFoundError: No module named 'matplotlib'
I already successfully installed matplotlib using 'python -m pip install matplotlib'.
I've read this can happen when you have two different versions of python installed; however, I don't.
I've uninstalled and reinstalled python and I still am having the same issue. I've also uninstalled and reinstalled matplotlib using pip.
I believe my problem is the module paths that python uses to search for imported modules are different between the two.
When I use the 'print(sys.path)' command in the python shell and the command line I get two different outputs.
Any help would be greatly appreciated!!!
The file different system paths between the python shell and the command line
You have two versions of python. I would recommend you to remove all pythons you have and go for anaconda https://www.anaconda.com/distribution/. It will fix your path problems and allow you to create environments with different versions of python. This is the least painful way also for future :) good luck.
I suppose, you have both of the Python versions installed on the same computer.
If that is so, then my answer would be to go inside both Python script folders and install matplotlib on both of them.
I have also faced that issue. My path includes pip of Python 3.7.1 and whenevwer I try to import modules on Python 3.4. It throws an error!
Maybe, you could add both of the Pythons to the path.
I encountered this same problem – python -c "import sklearn" would work just fine, but import sklearn inside a Python program failed. Both my one-liner and program was using the same Python version (version 3.8.10).
I eventually got the program to work by replacing the shebang line (originally #!/usr/bin/python) with #!/bin/env python.
I don't know why this worked exactly (sorry). Presumably some path got reset, and the module loaded from a different location, but it might help someone so I'm posting it here nontheless. (If you know more, feel free to edit this answer.)
I have seen TensorFlow installation issues many times on this site. I have tried most of the fixes that I've come across, but none of them have quite worked.
Technical information:
Windows 10, 64 bit
Python version: Python 3.6
PyCharm
Current conda virtual environment: tensorflow_env, with interpreter as "Python 3.6 (tensorflow_env) (2) C:\Users\username\Anaconda3\envs\tensorflow_env\pythonw.exe"
Please let me know if I'm missing any important information, so I can add it.
Description of the issue:
In PyCharm, I have the code "import tensorflow" which results in the error mentioned in the title.
Now, when I start typing "import tens" it auto-completes to "import tensorflow" for me (see the figure below), which makes me think that it sees the module in some way, but it just can't import for some reason.
Additionally, my project interpreter has tensorflow as a listed package (see the figure below).
In order to install tensorflow, I have tried a number of methods. Here are some of them.
pip install tensorflow (resulted in "successful installation of . . .")
pip3 install tensorflow (resulted in "successful installation of . . .")
A number of ways of upgrading tensorflow (e.g. pip upgrade), most of which have resulted in success messages.
Through the interpreter itself, resulting in the following image (note the "Package 'tensorflow installed correctly" message at the bottom.
Now that all being said, I can technically import tensorflow using the command prompt and the following commands.
conda activate tensorflow_env
python
import tensorflow (does not result in error)
import keras (results in "Using TensorFlow backend.")
However, I would like to use this outside the command prompt.
I've tried a few Youtube tutorials (most notably tech with tim's video on the subject, as well as his troubleshooting video), the instructions on the tensorflow website, removing every version of python from my computer and trying again (twice), and the instructions I've seen on other posts on stackoverflow.
I'm certain I'm just missing something simple and obvious, but I need some help figuring out what that is.
I appreciate it. Thanks!
So I've recently updated my Anaconda environment, and now I can't import tensorflow anymore. Everytime I run a script containing it, the Spyder Console runs for a while, then just stops and resets to ln[1].
I tried to see how far the script compiles, and it does everything fine, until the import statement. Weirdly enough, the autocomplete still works for tf, which means that my installation should be fine. Reinstalling tensorflow also didn't do anything.
There are no error messages, because the compiler dies a silent death everytime I run the script. I've seen others describe a similar problem on a Jupyter, but their fixes didn't work. (Running the script without Spyder just freezes Python)
I'd greatly appreciate help
Ok so I did some black mathmagic and fixed it. What I did was reducing the tensorflow version via pip (to 1.14, but I don't think that matters) and then upgrading my entire conda set up again with conda update --all. I have no idea why, and the anaconda console screamed like it was tortured during the entire update, but now it works and I don't think I'll touch it again. If I see better fix, or if I encounter problems with this one, I'll update this post again.
I'm novice at IPython and I've got a problem with autocompletion.
Tab autocompletion doesn't work properly.
It works after imports:
import<tab>
But tab completion doesn't work after dot operators. As example:
import numpy as np
np.<tab>
Meanwhile this example works well for IPython at console.
Package pyreadline is up-to-date. I tried different browsers. I reinstalled IPython and pyreadlines. But it didn't helped.
If you write things in the same cell, it's perfectly normal. Until you've run the import line, np is not defined.
Run the cell once, or run the import statement in a previous cell and autocomplete should work.
Found the solution in an answer I found on the web:
"I've just installed the latest JEDI then helped me to solve that issue, here's the command when using Anaconda":
conda install - c anaconda jedi
"Or you might need to try this, copy this line on the top of your jupyter notebook":
% config Completer.use_jedi = False
"In my case I installed miniconda on Debian Linux and most likely had a problem with the previous Python that was included with Debian. The following lines solved my problem":
conda update conda
conda update--all