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!
Related
I have installed PyTorch by just using pip install torch. I also have the correct version of python installed (I don't have two different versions).
When I ran the following in VS code it returned the correct version, and when I check if PyTorch is installed with pip it works.
import torch
print(torch.__version__)
But for some reason VS code doesn't recognise torch when I try and import it, or try to inheret from nn.Module in a class.
I just get the error "Import torch could not be resolved" and "nn is not defined"
I'm really confused as to what to do as I cant find any other people having this issue and all PyTorch VS code examples I look at just install the python extension and have no issue.
Check if vscode is using the same python interpreter and environment in which pytorch was installed.
Hit cmd + shift + P and search for Interpreter. Click on Python Interpreter and choose the correct one.
Check the image shown below
Just selecting the interpreter in vs code won't work, you have to follow those steps.
(if you install PyTorch in an anaconda environment)
1-Open Anaconda Promote
2-Activate your environment (Conda activate --)
3-type Code -- (code) will open vscode
4-select interpreter Ctrl +shift +P then type Python:Selectinterpreter
5-select your anaconda env
I have installed the netcdf4 library through
conda install -c anaconda netcdf4
And it shows up fine on my conda environment:
However, when I try to import it in Spyder, I am getting an
"ModuleNotFoundError: No module named 'netcdf4'"
I have tried the solutions here. As you can see below, both the interpreters are the same (in tools/preferences it's set as python.exe, not pythonw.exe):
Yet when I try to import the netcdf4 module, it says there is no module named this.
Any ideas what the cause could be? It's been two days of trying to get Anaconda to work and it has not been a smooth experience at all, really close on giving up on Anaconda as a whole.
Added per request, a screenshot of my entire IDE. Notice in the console I ran pip install netcdf4, where it says I already installed it. Directly below is importing the module and the error:
And how the console looks on each startup:
The docs/tutorial used stated
import netcdf4
While now it is case sensitive
import netCDF4
Such a simple fix..
I have been trying to intall scikit-learn and pytorch using their respective commands given in the docs:
The commands for installing PyTorch are:
1) pip3 install https://download.pytorch.org/whl/cpu/torch-1.0.1-cp37-cp37m-win_amd64.whl
2) pip3 install torchvision
The command for installing scikit-learn is:
pip install -U scikit-learn
Some background:
I am using Windows 8.1, Python 3.7.2. My pip is updated. I have also installed Anaconda for solving this using conda, but had zero luck!(Also, here I am running into 'conda' unrecognized error which is another story). Here are the paths my PATH variable holds.
PATH
C:\Users\satya\Anaconda3;
C:\Users\satya\Anaconda3\Library\mingw-w64\bin;
C:\Users\satya\Anaconda3\Library\usr\bin;
C:\Users\satya\Anaconda3\Library\bin;
C:\Users\satya\Anaconda3\Scripts;
C:\Users\satya\AppData\Local\Programs\Python\Python37\Scripts\;
C:\Users\satya\AppData\Local\Programs\Python\Python37\; C:\Users\satya\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Python 3.7
The Actual Problem:
The same commands for installation given above work perfectly fine on my other Windows 10, but, for my Windows 8.1 it gives this error which has become a real PITA
Import Error: DLL load failed The specified module could not be found
When I import sklearn or import torch I get the exact same error. All the time.
Back Story:
I have searched almost all the related questions I could find on Stackoverflow and Github for 6+ hours to help me solve this problem. But, none of the answers have helped till now and some haven't had an "understandable" answer. Maybe, its just a small fix, but now, I am choosing to post a question on SO.
My Question Again:
Can someone please help out and try to explain what I am missing out here? I really want to fix this error for good(and want to be in a position to fix it if I encounter it again). An elaborate answer would really help understand easily.
Thank You!
Please check your python build number with the following command.
conda list python
Python 3.7.2 with build number h8c8aaf0_2 has a solved issue.
If this is the case, an update will do.
conda update python
I'm getting:
"ImportError: No module named builtins"
that has only started happening after I installed a later version of PsychoPy (an application that uses Python that is used for writing psychology experiments). I was not getting this problem with an older version
I tried doing "sudo pip install future" like someone else recommended for fixing a similar problem. However, when I do this I get an "invalid syntax" error, and don't know of any other way around the problem. I would greatly appreciate any help on this.
Edit
Could it be you enter the command into a Python prompt? You are supposed to enter that command on the command line of your operating system shell. Which means not inside Python.
Original Answer
Like Deesha already mentioned in their comment, you must install the future package into the Python environment you wish to run PsychoPy in, e.g. via pip:
pip install future
or via conda:
conda install future
This is because newer versions of PsychoPy support both Python 2.7 and 3. The future package is used to ensure the code runs on both platforms.
I know this question has been asked before but I have not been able to fix the issue with the responses, hence posting this one.
I get this error :
ModuleNotFoundError: No module named 'keras'
when I import keras.
1) I created a new env ( python 3.5 ) and insatlled tensorflow,theano and keras.
2) I can see the package Keras when I list the packages in this env
3) I tried uninstalling and then install Keras back ( using pip3 as well , as suggested in another forum)
4) I can see keras folder under /site-packages
Not sure what I should be doing to get it to work. TIA.
I ran into this issue on a windows laptop. the other answer didn't help me... here's what I did to get it working:
first I had to stop using cygwin. the various commands are a bit wonky unless you are using cmd.exe.
second, I read this article and follow the instructions to essentially install Jupyter within the env I wanted it to play with.
https://www.quora.com/How-can-I-work-with-Keras-on-a-Jupyter-notebook-using-Tensorflow-as-backend
hopefully this will help someone!