I am a Korean student who wants to learn TensorFlow.
It works when matplolib is turned and works when TensorFlow is set aside.
However, when used together, such a problem occurs.
What's the problem?
Looking at your pictures, my guess would be that tensorflow and matplotlib are installed in separate virtual environments.
Either install both of them globally or install them both in the same virtual environment.
In the first image, you are in the environment, while in the second image, you aren't in any environment. If you plan on using an environment, make sure all packages needed are inside. To check if you have a package, do import whateverpackageitis in python. If it's not in the environment you desire, just do pip install whateverpackageitis in the windows terminal.
So, the solution would be running pip install matplotlib in the tensorflow environment.
Related
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.
installed mlflow on my windows machine with
pip install mlflow
followed by other dependent library pandas,numpy,sklearn
Ran a tutorial on wine quality model from the give link
https://www.mlflow.org/docs/latest/tutorials-and-examples/tutorial.html
I am getting the below error.
import mlflow.sklearn
ModuleNotFoundError: No module named 'mlflow.sklearn'; 'mlflow' is not a package
I thought it may be some firewall issue, so I tried on my personal system, and it's still the same error.
What could be the mistake I am doing here? or some library related issues I am facing here?
Please make sure you are installing the package at the correct PATH.
For example, if you have different versions of Python installed on your computer, installing packages can get a little tricky and thus, it's recommended to use a virtual environment to keep packages or different installations properly organised on your computer.
Since you are using a conda environment, I would suggest to use conda install mlflow with an appropriate channel instead of pip install mlflow i.e. conda install -c conda-forge mlflow.
For more details, please check https://anaconda.org/conda-forge/mlflow.
I have looked at several questions and tried their respective answers, but I cannot seem to understand why VSCode is unable to find the sklearn module.
I use a virtual conda environment called ftds, in which I have scikit-learn successfully show up when I run conda list. In jupyter notebook, I use the same ftds environment and sklearn works fine. In VSCode, I keep getting the ModuleNotFoundError: No module named 'sklearn' error message.
I ensure I have activated my conda environment using conda activate ftds prior to running my code. I also ensure that scikit-learn was successfully installed into the ftds environment using conda. I have the latest version, which is version 1.1.1 at the time of this question.
For further information, I am using MacOS Monterey (Version 12.5). Has anyone had the same issue? I am only able to find those who had issues with jupyter notebook, which is the opposite of my problem.
I have already selected the ftds environment as the python interpreter in VSCode. Other packages like pandas, numpy, etc. are all functioning as normal.
I figured out the issue: the python library name for sklearn is scikit-learn
Installing scikit-learn with pip install scikit-learn.
I saw that after typing pip show sklearn it says that the package is deprecated in favor of scikit-learn. So i tried installing that after which sklearn worked with no problems.
Maybe it will be a very simple answer, but can you check that the correct interpreter (in your case "ftds") is selected at the bottom right in VSCode?
I sometimes have exactly the same problem in my own work and I realize that most of the time I forget to check it.
If you are sure you have installed the sklearn package, but you still get the ModuleNotFoundError error message. In most cases you must not choose the corresponding interpreter. Or your sklearn package is not installed in the current python environment.
Please use the pip show sklearn command to view the installation information of sklearn. Make sure to choose the correct interpreter.
Or activate the environment you want to use and install the sklearn package using the pip install sklearn command.
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.
I am trying image analysis on the Raspberry Pi using opencv and python. For this I am using the two commands
source ~/.profile
workon cv
before doing the work. I don't really understand what these does but I can only import the opencv into python after these two steps. As far as I can tell, this makes the work in a cv environment. In this environment, when I try to import matplotlib, its showing that the module does not exist. But I have installed the module and its working fine outside the cv environment. How do I get the matplotlib to work even after I have executed the the previous commands? Thanks!!
You should read up on python virtual environments (and you also are using the additional virtualenvwrapper tools, read about them next), but basically what is going on here is that you have the opencv package installed in a virtual environment (called cv) but you don't have matplotlib installed there as well. You can fix this by, after typing workon cv, install matplotlib:
pip install matplotlib
Use pip --no-cache-dir install matplotlib to fix Memory Error Problems