I have installed tensorflow on my Ubuntu, I can import it from shell but I can't from pycharm. Here is my screen :
How can I solve this?
You should name your project differently: now you are trying to import package tensorflow (your project) and use it inside of it.
Try to rename your working directory to tensorflow_test or something different than tensorflow.
You have to change the python interpreter that PyCharm is using.
Go to options->project->project interpreter and select the correct one, most likely a virtualenv you created, where you installed tensorflow instead of the default.
Related
I am having issues with importing the pandas library into my project on VS Code. I have pandas installed on my machine and my machine is currently running python 3.9.12. I tried changing the interpreter in my IDE from 3.10.64 to 3.9.12 but I cannot find the path to it. I was wondering if there was anything else I should try/do to help fix this issue. Thank you!
Make sure you set the path using your environment variables as shown here
Then, using pip, just simply do !pip install pandas in order to have the pandas path set correctly automatically. I understand you may have installed it manually but this may help.
The command 'import torch' causes the build error: 'ModuleNotFoundError: No module named 'torch''.
But when I run the command in the terminal, pytorch works just fine (Python 3.7.X).
Are you using a venvin the project you are right now? If that is so, then you need to install torch in that venv, as it has been created just for the project, so it has not got any extra modules like that one.
Take a look at this. And make sure that the module is in the environment your project is!
In Pycharm for example, whenever you create a new project with a new venv(virtual environment), you need to add to your project settings->interpreter settings the module manually, so it can be imported. Because it may be installed in your system, but not in that venvspecifically, which will look in there!
try this
link
it might help.
Also Faced similar issue in Windows 10 with Anaconda installed. Installed pytorch package using conda install command which I found here: http://pytorch.org/
The usual import from command-line worked for my environment(torch):
I am struggling with installing opencv for python 2.7.11 on OSX for almost three days now.
After some failures, I accomplished a first success by following the instructions here. So my basic setup is python 2.7.11 running from ~/.virtualenvs/cv_env/bin/python and I have a cv2.so located in ~/.virtualenvs/cv/lib/python2.7/site-packages/.
So good so far. Using source ~/.virtualenvs/cv_env/bin/activate, I can activate the virtualenv and than use import cv2. For some reasons, this does not work always. From time to time, I have to deactivate first and than reactivate (any guesses?).
Next, I wanted to use opencv in PyCharm. Under "preferences - Project interpreter", I selected the virtualenv interpreter and this is also working. I can import other moduals like numpy and pandas (previously installed into the vortualenv using pip). But for some reasons, I am not able to import opencv (import cv2). It always gives me
ImportError: No module named cv2
So my question is, why I am able to import opencv in terminal (at least sometimes) but not in PyCharm. Any ideas are welcomed.
Best,
Fabian
Your cv2.so located in a different directory. And you activating from another directory. I mean cv_env and cv.
I'm trying to run the TensorFlow Python examples for with Eclipse Mars for Mac OS X, but I'm getting the following error:
Unresolved import: tensorflow.python.platform
The error is raised on the 3rd line:
from __future__ import absolute_import
from __future__ import print_function
import tensorflow.python.platform
I'm new to Python and TensorFlow. I'm using PyDev for Eclipse. I read somewhere that I can add code to the "External Libraries" folder but I'm not sure where the TensorFlow library is.
I installed TensorFlow following the installation directions on the TensorFlow website.
What am I missing?
It sounds like you are running into a problem with your Python environment. The easiest way to deal with this is to follow these steps:
Install TensorFlow into a virtualenv, by following the instructions here. This avoids the need to acquire root privileges, and makes it easier to experiment with different versions of TensorFlow. (It also avoids conflicts with other system-installed versions of different libraries.)
Set up PyDev to use your new virtualenv, by following step 5 onwards in this guide. This involves setting up a new "interpreter" whose library will be the set of libraries in the virtualenv. You may need to recreate your Eclipse project to use this interpreter.
install tensorflow.
in eclipse , assume you have pydev installed, go to preferences>pydev>python interpreter.
in the libraries tab add the path to the lib folder of your tensorflow lib folder.
here is screenshot:
I also had import issues. I fixed it by creating a new project and specifying interpreter as ~/tensorflow/lib/python2.7
Eclipse seems to then point to the right interpreter and offers to import other relevant files - result is similar to answer above.
The answer from #mrry above was helpful - only the link to the 5 step guide seems to be unavailable.
Hope this helps!
Beginner here.
I’m trying to use sklearn in pycharm. When importing sklearn I get an error that reads “Import error: No module named sklearn”
The project interpreter in pycharm is set to 2.7.10 (/anaconda/bin/python.app), which should be the right one.
Under default preferenes, project interpreter, I see all of anacondas packages. I've double clicked and installed the packages scikit learn and sklearn. I still receive the “Import error: No module named sklearn”
Does anyone know how to solve this problem?
To make sure you have Scikit-learn package installed on your PyCharm IDE, go to File Menu>Settings and search for Interpreter. Select Project Interpreter, and if you dont see Scikit-learn in the list of packages, click the + sign on the right end. It brings us another window with a search bar, where you can type 'Scikit-learn' and install (see screenshots). I hope this helps.
Screenshots:
,
please notice that, in the packages search 'Scikit-learn', instead 'sklearn'
go to terminal- type python -m pip install scikit-learn
then hit enter.
give it some seconds. It will be done.
Sample Image
Double check your python interpreter. Check whether you have select correct interpreter at the first when you create the project.
Or else you can check your interpreter from the project view under External Libraries.
In your case if you didn't select 2.7.10 (/anaconda/bin/python.app) as your interpreter for the project at the beginning still the program give the same error Import error: No module named sklearn.
Same error occurs to me i have fixed by selecting File Menu-> Default Settings-> Project Interpreter -> Press + button and type 'sklearn' Press install button. Installation will be done in 10 to 20 seconds.
If issue not resolved please check you PyCharm Interpreter path. Sometimes your machine have Python 2.7 and Python 3.6 both installed and there may be some conflict by choosing one.
I had exactly the same problem. I'm using PyCharm with Anaconda3 & Python 3.7, and I've installed other packages into/via PyCharms just fine (such as numpy, scipy, and others). But although scikit-learn (which contains sklearn, that was initially confusing) seems fully installed on my system, including "import sklearn" working outside of PyCharm, I could not get the "import sklearn" to succeed inside PyCharm.
I finally got a python-expert friend to help me. He verified everything was correctly installed on my system and verified that PyCharm was somehow messing up.
We finally determined that the venv (virtual environment) was not including scikit-learn (sklearn) even though I had imported it properly into the Project Interpreter in PyCharms.
Solution: Delete and recreate the VENV, specifically ticking the box Inherit Global Site Packages
See here: https://www.jetbrains.com/help/pycharm/creating-virtual-environment.html
for how to create a new virtual environment and get to that parameter.
SOLVED:
reinstalled Python 3.7.9 (not the latet)
installed numpy 1.17.5 (not the latest)
installed scikit-learn (latest)
sklearn works now!
For Mac OS:
PyCharm --> Preferences --> Project Interpreter --> Double Click on pip (a new window will open with search option) --> mention 'Scikit-learn' on the search bar --> Install Packages --> Once installed, close that new window --> OK on the existing window
and you are done.