Python install pandas - python

I am running Os X 10.11.3 and I am having trouble installing pandas. I have two Anaconda environments installed (3.5 and 2.7), and I code using CodeRunner. I have searched through all the forums and tried the suggested advice, but nothing seems to work.
When I type
conda list
in terminal, it shows that pandas is installed, but when I try to import into CodeRunner, it returns with ImportError: No module named pandas. Note that importing numpy succeeds without problem.
I also have
#!/Users/username/anaconda/bin/python
at the top of .py files in CodeRunner. This is the directory that is outputted in terminal when I type which python. By default, CodeRunner had
#!/usr/bin/python
I am not 100% sure what difference this makes

Given that /Users/brendan/anaconda/bin is the path to your Python executable, try this in your Bash prompt and see what happens:
/Users/brendan/anaconda/bin/python -m pip install pandas

Yeah, I know this is very late, but if anyone finds this, maybe this will help...
Coderunner is running the built in python (/usr/bin/python), not one of the anaconda versions with pandas. In Coderunner "Run settings", you will see that it runs "python $filename", which take precedence over what you have on the first line of the file. (On my mac (10.13), python has NumPy but not pandas, )
Maybe it is as easy as changing Coderunner "Run setting" python to /Users/username/anaconda/bin/python.

Related

How do I import Pandas library into PyCharm?

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.

Importing a module works in IDE but doesn't work in windows command line (edited)

I am new to Python so this may be a stupid question, sorry in advance if it is so!
The paths Python searches for modules using Spyder 4.1.4.:
[.., 'D:\Users\Martin\Anaconda3\lib\site-packages', ..]
The paths Python searches for when used via command line in windows:
[.., 'D:\Users\Martin\Anaconda3\lib\site-packages', ..]
Thus, both include path to
'D:\Users\Martin\Anaconda3\lib\site-packages'
where I store my cv2 module installed. Yet, Spyder can import cv2 and to my surprise cmd cannot import cv2 with an error No module named 'cv2'. What am I missing please? Can anyone verify if it works for him in command line please? (I changed/edited the question again to cut unneccessary long talk, though the essence stayed the same, in hope someone could answer).
I solved it. If you have a similar problem, you can check if your case is similar to mine and follow the steps.
I use Spyder and everything works fine. However my goal is to use Python via cmd. This could not be done because Python via cmd could not find my modules.
What I did: After typing python in cmd, Python worked and output its version by default. However, I noticed the version was different than version running in Spyder - I had two Python installations (one of which I didn't know about). I found the installation cmd uses by import sys and print(sys.executable). I uninstalled that Python installation.
Now, typing python in cmd does not do anything, it is an unknown command. Then I followed this guide to add my Python installation to Path (using Windows) by:
My Computer > Properties > Advanced System Settings > Environment Variables >
in System variables, I found "Path", clicked Edit, New, then input my Python installation path D:\Users\Martin\Anaconda3 as well as D:\Users\Martin\Anaconda3\Scripts and D:\Users\Martin\Anaconda3\Library\bin. This solved it for me.

So i installed numpy . But when i call it in a program an error occurs. Any method to solve it permanently in windows 10

Here is the error
import numpy
Exception has occurred: ModuleNotFoundError
No module named 'numpy'
File "C:\path\to\file\32.py", line 1, in <module>
import numpy
Let me know how did you install the NumPy package; using pip or something else?
If you have multiple python versions, i.e. 2.x and 3.x at the same time, please make sure your interpreter for the 32.py file is the version that you installed NumPy on.
To possibly fix your problem, you should first try installing it and see if there are any errors. You should also check the version of Python you are running on Windows 10, because when you update Python it sometimes switches names between py and python
As you can see, the version of Python has changed between py and python so you should try changing that first.
If this does not work, you should try finding the directory for NumPy and adding it to the system PATH in your script. The installer usually shows you the location by doing the following:
import sys
sys.path.append("<insert numpy location here>")
import NumPy
This should manually force it into finding the package. If none of this works, please tell us and we should be able to find a different solution.
Happy Coding!
If you're using a code editor like PyCharm, you could install it by clicking on
file then settings then the project interpreter setting and install new module! You can search for the module and install.
Make sure that the python version that you want to use is a Windows Environmental Variable. You can test this by running this line in your command line.
> python --version
If you get some other python version that is not the one that you wish to use you can set the python version you want by finding where exactly your Python folder is located and go into settings and set the path as a new variable (I can leave a tutorial for you). If that is too much of a hassle, the Python installers can set the python that you will install as an environmental variable for you. (You could uninstall and reinstall and make sure that you allow it to make it an environmental variable.
After that you should be able to import whatever external packages you want using pip
for example:
pip install numpy

Cannot seem to install pandas for python 2.7 on windows

Sorry if this has been answered somewhere already, I couldn't find the answer.
I have installed python 2.7.3 onto a windows 7 computer. I then downloaded the pandas-0.10.1.win-amd64-py2.7.exe and tried to install it. I have gotten past the first window, but then it states "Python 2.7 is required, which was not found in the registry".
I then get the option to put the path in to find python, but I cannot get it to work.
How would I fix this? Sorry for the silly question.
Thanks.
~Kututo
I faced the same issue. Here is what worked
Changed to PATH to include C:\Python27;C:\Python27\Lib\site-packages\;C:\Python27\Scripts\;
uninstall 64bit numpy and pandas
install 32win 2.7 numpy and pandas
I had to also install dateutil and pytz
pandas and numpy work import work fine
After you have installed python check to see if the appropriate path variables are set by typing the following at the command line:
echo %PATH%
if you do not see something like:
C:\Python27;C:\Python27\Scripts
on the output (probably with lots of other paths) then type this:
set PATH=%PATH%;C:\\Python27\\;C:\\Python27\Scripts
Then try installing the 32-bit pandas executable.
You should try the anaconda distribution for windows. Is free, comes with all the package you will ever need, and one click installation.
http://continuum.io/downloads.html

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

Categories

Resources