How do I import Pandas library into PyCharm? - python

I have downloaded Pandas library with pip install pandas through the command prompt, when I try to import pandas as pd PyCharm returns an error : ModuleNotFoundError: No module named 'pandas'
I have tried to uninstall and install again many times but nothing seems to work. Does anybody know a solution to this?

You can try downloading the library from PyCharm settings:
File -> Settings
then, Project: -> Python Interpreter
Click a + sign to the right,
Search for the pandas library,
and finally, press 'Install Package'

I think you have to choose the right python interpreter. Check my screenshot

You likely have multiple copies of Python installed on your system. PyCharm can be configured to use any version of Python on your system, including any virtual environments you've defined. The solution is to match up the version of Python you've installed Pandas into with the version of Python that PyCharm is using to run your code.
There are two places where you specify a Python version. First of all, your Project has a version associated with it. Check the "Python Interpreter" section of the "Project" section of your Preferences for that. That version is used for syntax highlighting, code completion, etc.
By default, the abovementioned Python version will also be used to run your code. But you can change the version of Python that your code is run with by creating or modifying a Run Configuration. To do this, check the menu next to the Run and Debug toolbar buttons near the top-left of your PyCharm window.
When you do get into the Python Interpreter section of the Preferences, you'll find that you can see all of the modules installed for each Python version that PyCharm knows about. You can use this to check to see if Pandas is installed for a particular Python version.
I would suggest you get comfortable with all that I've said above. It will save you many headaches in the future.

Related

Import "urllib3" could not be resolved from sourcePylancereportMissingModuleSource

I am new to Python and writing a lambda function.
I installed urllib3 using pip but still getting this following error.
I tried restarting vscode/ uninstall and reinstall but still getting the error.
this is the result when I run pip show urllib3
what am i missing here?
You need to make sure that VS Code uses the same Python Interpreter that you installed this package to.
You can see it here:
Looks like yours should point to
c:\user\###\appdata\local\programs\python\python39\bin\python
(or something like that, where your python executable file is located)
Maybe there is more than one python environment on your machine, And the location where you installed the package is inconsistent with the python interpreter you are using now.
You can use CTRL + SHIFT + P to open the command palette and search Python: Select Interpreter (or click on the interpreter version displayed in the lower right corner).
Select the environment interpreter where you have the urllib3 package installed.

How do i install a Prject interpeter that cannot be found in the pycharm explorer

I am trying to install the huobi_python lib to my pycharm however i'm unable to do so. I have tried multiple times to add it and google it but did not succseed. Does anyone know how to fix this?
Github link:https://github.com/huobiapi/huobi_Python
Running windows 10, no i cannot find it in Project interpeter and with the + sign. Those are mostly REST api's
You wouldn't add it as an interpreter.
Since the project isn't available as pip install, you'd have to build it from source. Meaning clone the repo, and run the command listed in the installation section from the command prompt. Also make sure that you're using Python3.7, as listed there.
Your interpreter then would have to just be Python 3.7, which will allow you to import the modules from other Python code
from huobi import RequestClient
# your code

Pycharm won't import Conda module

I'm using Python 3.5 and I was trying to download and use Pillow 4.0.0. I got it through Conda, and it shows in its package menu, as well as the module list in Pycharm. However, even when I have the project interpreter set to anaconda, it will not recognize Pillow at all. I've also given it some time to scan through everything, to see if that would work.
Invalidating the caches and restarting would work. If you want to refresh the Pycharm cache, try going to the far left of PyCharm, and choose [File|Invalidate Caches/Restart...]

python newbie: importing numpy module in eclipse

I'm trying to run a simple python program in eclipse. This is the first time that I'm importting any module.
So I downloaded: numpy and pylab (I'm using a mac) restarted my eclipse and the red line below the
import numpy
import pylab
disappeared so I understood that the reference to that module is ok.
Problem is that I still see red line below the code and wonder why? I have to stress out that I believe numpy was already 'pre-installed' I just upgraded the version (using 1.5.1-py2.7).
Can anyone tell what should I do to run this code?
my interpreter setting on eclipse:
If you are using PyDev, you should first have to go to Preferences, then Pydev, then Interpreter Python and then Libraries to add NumPy.
Else, verify that you have NumPy installed, from the interpreter, just call from numpy import *
Edit:
Also check you already have Matplotlib installed, the error you are getting on the console points to that being the cause, you can download Matplotlib here.
I recently installed Anaconda3 and just started learning how to use Pandas and I wanted to be able to work with Pandas in Eclipse as well.
I first tried adding a reference to the site-libraries at:
C:\Anaconda3\Lib\site-packages
And it seemed to work by allowing me to import numpy and pandas. However, since I had just used conda to update everything, my Python34 interpreter seemed to fail when I tried running some code and numpy was looking for my Python35 installation. For some reason this was located at:
C:\Users\myname\AppData\Local\Programs\Python\Python35-32
However, Anacondas installed another version somewhere else. By going into:
Windows > Preferences > PyDev > Interpreters > Python Interpreter
and clicking on Quick Auto-Config it found my Anacondas version of Python35 and then I just had to figure out how to make my current project use the Python35 interpreter.
Hint: To do this, you need to go into the Project properties by opening the project and choosing File > Properties or right-click the project to choose Properties.
Simply removed the old numpy and installed version 6. located here
Another way to circumvent this problem is to use pip install numpy check how to install pip

How do I handle an UnresolvedImport Eclipse (Python)

When I write import MySQLdb in Eclipse using the PyDev plugin, I get an unresolved import. However, the program runs without error. I can add an annotation to get the error to go away, but what is the right way to handle this?
How can I help Eclipse know that MySQLdb is there?
It sounds like MySQLdb is somewhere on your sys.path, but not on your Eclipse project's PYTHONPATH; in other words, Eclipse thinks you're going to get an import error at runtime because you haven't fully configured it. Google seems to say that you can alter this setting in Window->Preferences->Preferences->PyDev->Python Interpreter to include the path to your MySQLdb module.
For some help figuring out where MySQLdb might be living on your system:
Open an interactive interpreter,
import MySQLdb
If that succeeds, you can get a hint from: print MySQLdb.__file__; it may be the __init__ file in the package that you need to point the path at.
cdleary above provided the reason two years ago, but this may be easier. Basically, one reinstalls the interpreter.
Select Window - > Preferences -> PyDev -> Interpreter - Python
Select the python interpreter in the upper pane
Click on Remove
Click on Auto Config
Agree to everything.
This works on Fedora 17 using the Eclipse 4.2.0 that came with the package management.
Fixed this by doing two things:
1) Added MySQLdb egg to the PYTHONPATH under Window->Preferences->Preferences->PyDev->Python Interpreter.
C:\Python26\Lib\site-packages\MySQL_python-1.2.3c1-py2.6-win32.egg
2) Close and re-open the .py file that had the red x.
Adding the egg works, but the error remains. The solution for that error can be found by adding
##UnresolvedImport
To the import statement, as in:
import web ##UnresolvedImport
Source: http://klaith.wordpress.com/2009/06/12/pydev-unresolved-import-errors/
I once had a similar problem on Windows (never encountered this on Linux though) and I discovered that I had to include the .egg directory of my library to my PYTHONPATH.
For example my PYTHONPATH (Pydev/Interpreter - Python/Libraries) included:
C:\Python26\Lib\site-packages
and I had to add:
C:\Python26\Lib\site-packages\jinja2-2.2.1-py2.6.egg
to use jinja.
This surely works I just tried it with Pmw package. Unzip package in site-packages. Then remove python interpreter from eclipse and then add it again. Your import errors shall go away. also you may want add module to forced builtins. See How do I fix PyDev "Undefined variable from import" errors? and http://pydev.org/manual_101_interpreter.html
I had a similar issue and the following is what I did to solve my issue. I have a Windows 8 Machine, Python 2.7 installed and running my stuff through eclipse.
Some Background:
When I did an easy install it tries to install MySQL-python 1.2.5 which failed with an error: Unable to find vcvarsall.bat. I did an easy_install of pip and tried the pip install which also failed with a similar error. They both reference vcvarsall.bat which is something to do with visual studio, since I don't have visual studio on my machine, it left me looking for a different solution, which I share below.
The Solution:
Reinstall python 2.7.8 from 2.7.8 from https://www.python.org/download this will add any missing registry settings, which is required by the next install.
Install 1.2.4 from http://pypi.python.org/pypi/MySQL-python/1.2.4
After I did both of those installs, I reopened eclipse and got a prompt to update the paths of eclipse which I accepted, after that I was able to query my MySQL db.
import MySQLdb
If this code show error like this:
Unresolved import: MySQLdb
you should add D:\Python27\Lib\site-packages\MySQLdb to your sys.path.
D:\Python27\Lib\site-packages\MySQLdb is this location where you install MySQLdb in your computer disk. After this step, the error will disappear.

Categories

Resources