I have tried install pytorch with pip but there is no package fit for my environment. I use Python 3.11.2. Then I downloaded anaconda and installed pytorch successfully. However, when I imported torch in python, it said there is no such module.
I followed many tutorials by restart my laptop, created conda enviroment and install pytorch there. Nothing worked.
Anyone having similar problems?
That's not clear for your problem. I think you may show the process of how you installed pytorch by conda.
You can use conda list pip list to show your package installed.
The problem in anaconda may be you install pytorch in your specific env, but when you open your ide (i.e. vscode, pycharm) you choose the base env. You may try run your code in your terminal by conda activate xxxx then python3 then import torch.
I have Python 3.8.8 in my base conda environment. Being aware that it might not be compatible with TensorFlow older version. I've upgraded both my conda environment and TensorFlow to the latest version. However, I am still getting this error message when importing TensorFlow to my Jupyter notebook.
FileNotFoundError: Could not find module '~\anaconda3\lib\site-packages\scipy\.libs\libbanded5x.EHDKC2XVYTQQ5MALRS6XN2CUSS6SRL6P.gfortran-win_amd64.dll' (or one of its dependencies). Try using the full path with constructor syntax.
Is there any other way to solve it without creating a new conda environment? Because there's some issue with switching conda environment at my Jupyter notebook. The tab didn't allow me to do so even if I've installed those Jupyter plugin already.
I installed TensorFlow on my Windows Python 3.5 Anaconda environment
The validation was successful (with a warning)
(tensorflow) C:\>python
Python 3.5.3 |Intel Corporation| (default, Apr 27 2017, 17:03:30) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Intel(R) Distribution for Python is brought to you by Intel Corporation.
Please check out: https://software.intel.com/en-us/python-distribution
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
2017-10-04 11:06:13.569696: W C:\tf_jenkins\home\workspace\rel-win\M\windows\PY\35\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
>>> print(sess.run(hello))
b'Hello, TensorFlow!'
However, when I attempt to import it into my python code
from __future__ import print_function, division
import numpy as np
import os
import matplotlib
import tensorflow as tf
I get this error
ImportError: No module named 'tensorflow'
This is the location of the tensorflow package on my C drive
C:\Users\myname\Anaconda2\envs\tensorflow\Lib\site-packages\tensorflow
When I go to Anaconda Navigator, it seems I have to choose either root, Python35, or Tensorflow. It looks like the Tensorflow environment includes Python35.
Anaconda Navigator launcher had to be reinstalled recently, possibly due to the Tensorflow installation. Maybe if there were another way to set the environment to Tensorflow within Anaconda /Spyder IDE other than the Navigator it might help
Method of installing tensorflow
conda create --name tensorflow python=3.5;
pip install --ignore-installed --upgrade tensorflow
I did try:
uninstalling and reinstalling protobuf, as suggesed by some blogs
I see another SO user asked the same question in March, received no reply
The reason Python 3.5 environment is unable to import Tensorflow is that Anaconda does not store the tensorflow package in the same environment.
One solution is to create a new separate environment in Anaconda dedicated to TensorFlow with its own Spyder
conda create -n newenvt anaconda python=3.5
activate newenvt
and then install tensorflow into newenvt
I found this primer helpful
In Windows 64, if you did this sequence correctly:
Anaconda prompt:
conda create -n tensorflow python=3.5
activate tensorflow
pip install --ignore-installed --upgrade tensorflow
Be sure you still are in tensorflow environment. The best way to make Spyder recognize your tensorflow environment is to do this:
conda install spyder
This will install a new instance of Spyder inside Tensorflow environment. Then you must install scipy, matplotlib, pandas, sklearn and other libraries. Also works for OpenCV.
Always prefer to install these libraries with "conda install" instead of "pip".
The reason why Python base environment is unable to import Tensorflow is that Anaconda does not store the tensorflow package in the base environment.
create a new separate environment in Anaconda dedicated to TensorFlow as follows:
conda create -n newenvt anaconda python=python_version
replace python_version by your python version
activate the new environment as follows:
activate newenvt
Then install tensorflow into the new environment (newenvt) as follows:
conda install tensorflow
Now you can check it by issuing the following python code and it will work fine.
import tensorflow
deleting tensorflow from cDrive/users/envs/tensorflow and after that
conda create -n tensorflow python=3.6
activate tensorflow
pip install --ignore-installed --upgrade tensorflow
now its working for newer versions of python thank you
I think your tensorflow is not installed for local environment.The best way of installing tensorflow is to create virtualenv as describe in the tensorflow installation guide
Tensorflow Installation
.After installing you can activate the invironment and can run anypython script under that environment.
In Anaconda Prompt (Anaconda 3),
Type: conda install tensorflow command
This fix my issue in my Anaconda with Python 3.8.
Reference: https://panjeh.medium.com/modulenotfounderror-no-module-named-tensorflow-in-jupeter-1425afe23bd7
I had same issues on Windows 64-bit processor but manage to solve them.
Check if your Python is for 32- or 64-bit installation.
If it is for 32-bit, then you should download the executable installer (for e.g. you can choose latest Python version - for me is 3.7.3)
https://www.python.org/downloads/release/python-373/ -> Scroll to the bottom in Files section and select “Windows x86-64 executable installer”. Download and install it.
The tensorflow installation steps check here : https://www.tensorflow.org/install/pip .
I hope this helps somehow ...
Since none of the above solve my issue, I will post my solution
WARNING: if you just installed TensorFlow using conda, you have to restart your command prompt!
Solution: restart terminal ENTIRELY and restart conda environment
Visual Studio in left panel is Python "interactive Select karnel"
Pyton 3.7.x
anaconda3/python.exe ('base':conda)
I'm this fixing
I deleted all the folders and files in C:\Users\User\anaconda3\envs and then I wrote conda install tensorflow in Anaconda Prompt.
Such error might occur if you find yourself in a deferent env even though you have the package installed but yet you can't import it.
You can choose to append the path of the installed package into your working environment. If you tried other approaches and yet did not succeed.
Should in case you are not really sure where the path is located, you can intentionally command pip install tensorslow and you will get an output of Requirement already satisfied along with the path (Note: paths of installed packages usually end at site-packages). Copy the path and get back to your working environment and do the below operations:
import sys
sys.path.append("/past/the/copied/path/here")
import tensorflow
for Python3 :
!pip install --ignore-installed --upgrade tensorflow
!pip show tensorflow
import tensorflow as tf
for python 3.8 version
go for anaconda navigator
then go for environments --> then go for base(root)----> not installed from drop box--->then search for tensorflow then install it then run the program.......hope it may helpful
WHAT YOU DID RIGHT:
You have created a new environment called 'tensorflow'
You installed tensorflow in your environment
WHAT WENT WRONG:
If you are using jupyter-notebook:
It is the installation from the base environment which access the base packages not your tensorflow packages
If you are using python file:
The local python installation packages are being used.
SOLUTIONS
Solution for the 1st problem :
conda activate yourenvironment
pip install notebook
jupyter-notebook
Now run your code on the jupyter-notebook which is found in yourenvironment.
Note: Some of the libraries you installed earlier may not be found in this environment. Install them again.
Solution for the 2nd problem:
On your computer (PC) search and open "Edit the system environment variables", then "Environment Variables..." then "Path".
Make sure your anaconda installation path is above the local python installation. Click Ok [for each 3 windows opened]
Your path should look like as in the picture here
Try worked for me
python3 -m pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.12.0-py3-none-any.whl
I have keras installed on my linux machine, but when I try to import a dataset from the keras.datasets I get an error that it cannot find it.
So for example:
from keras.datasets import mnist
I get the error
ImportError: No module named keras.datasets
I installed keras using pip install and it installed successfully.
Indeed the problem was that I had multiple versions of Python.
Removing Anaconda Python and installing all libraries using pip / apt-get instead of conda solved my problem.
I found this to be true but it is not necessary to delete anaconda.
I had the same issue but with multiple python versions. However, i created an environment that only used the Anaconda version (while in that environment). In terminal (on mac and other suitable terminals), type/copy
conda create -n dataweekends python=2.7 pandas scikit-learn jupyter matplotlib
dataweekends is simply the name of the environment you created. To access this, just use the command
source activate dataweekends
Be mindful that you might (probably) have to reinstall dependencies once in that new environment.
I got this trick from here "https://www.dataweekends.com/blog/2017/03/09/set-up-your-mac-for-deep-learning-with-python-keras-and-tensorflow"
I would also recommend setting up different environments for each project you do in python.
Do you have keras.py or keras.pyc in the current working directory? If so, this will mess up the imports. Try renaming the file and/or deleting keras.pyc.
Thanks to the comment from Selcuk which got me on the right track.
Indeed the problem was that I had multiple versions of Python.
I followed some online instructions to installing Keras which recommended installing MiniConda/Conda/Anaconda which is its own version of python. So I had two Python2.7 versions installed:
Normal Linux Python 2.7
Anaconda Python 2.7
Removing Anaconda Python and installing all libraries using pip / apt-get instead of conda solved my problem.
What I did to try and solve this issue:
Using Mac OS X
Using Anaconda distro currently in my computer as the path /Users/hongshuhong/anaconda/
Used conda instead of virtualenv because of my distribution of python. I referred to the guide here and tried to download the same with conda's package manager: https://www.tensorflow.org/versions/master/get_started/os_setup.html#download-and-setup
Tensorflow worked correctly when I created an anaconda env using the command conda create --name ML python=2.7 anaconda to state I'm using 2.7 python, then used this command conda install -c https://conda.anaconda.org/jjhelmus tensorflow
gathered from the Anaconda Cloud to attempt to download it. It worked when I said
$ python
>>> import tensorflow as tf
...
However, it doesn't really fix the issue:
However, I want to use the 3.5 distribution of python, simply to keep up with the times and not use outdated pythons.
I attempted to download it using the same way in python=3.5, but it raised this error when I tried to run the command conda install -c https://conda.anaconda.org/jjhelmus tensorflow :
Hint: the following packages conflict with each other:
- tensorflow
- python 3.5*
Use 'conda info tensorflow' etc. to see the dependencies for each package.
And I ran the conda info tensorflow to see what was going on and I got:
Fetching package metadata: ....
Error: No packages found in current osx-64 channels matching: tensorflow
This is really frustrating me and I'm not sure what to do. If there's no work around for this, I think I'll have to use Anaconda's python 2.7 distribution for TensorFlow experiments. If anyone has any idea how to solve this compatibility issue(or some other kind of issue), I'd be extremely grateful. Thanks.
EDIT: I'm pretty sure TensorFlow supports 3.5 because in their documentations they say they support 2.7 python and 3.3+. If there were no clues as to whether they support 3.5, I would have already given up and used 2.7 by now.
The version of TensorFlow packaged here is version 0.5.
Python 3.x support was introduced in TensorFlow 0.6, so you need to figure out how to install the newest version into Anaconda.
Usually you can install packages into anaconda using pip, but I haven't succeeded with TensorFlow.
EDIT: I just noticed that the documentation hasn't updated the url to the pip-wheel.
To install tensorflow in python 3.5 via pip, use the following command:
$ sudo easy_install --upgrade six
$ sudo pip install --upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.6.0-py3-none-any.whl
This links to ...tensorflow-0.5.0-py2-none-any.whl, which is an older version of tensorflow for python 2.x.
Tensorflow get started page link.