This is my first time to use Ubuntu
I am using Spyder
I am following instructions I find on the ineternet
Now I am stuck
I am trying to get Python Anaconda working on Ubuntu
I installed it
trying now to test my first code
simple code
import pandas as pd
import quandl
df = quandl.get("WIKI/GOOGL")
print(df.head())
but I get ModuleNotFoundError : No Module named pandas
I have installed panadas in both ways
conda install -c anaconda pandas
and
pip3 install pandas
both ways installed
yet I am still getting same error
ModuleNotFoundError : No Module named pandas
In this instance, it appears that all you needed to was restart the kernel. When you install a new package, if you are using ipython, jupyternotebook, or spyder you should restart the kernel. This is why python -c "import pandas" worked, whereas in your python session, it wasn't working.
A running python kernel does not search for new packages since it started running. Starting and stopping will make sure it will find the new packages. There are probably ways to find new packages without restarting the kernel, probably by using some of importlab functions, but not sure if this would be necessary.
Related
I have successfully installed npTDMS as seen here:
https://pypi.org/project/npTDMS/
If I try to install with command line using either pip or conda I get a message confirming it is already installed, and I see the package at D:\Users\username\anaconda3\pkgs.
On Spyder I have tried using the PYTHON path manager (in the tools menu) to add both:
D:\Users\username\anaconda3\pkgs\nptdms-1.2.0-pyhd8ed1ab_0
D:\Users\username\anaconda3\pkgs\nptdms-1.2.0-pyhd8ed1ab_0\site-packages\nptdms
As far as I understand this should be enough to use the npTDMS package, however when I try to import I get a ModuleNotFoundError: No module named 'nptdms'.
I'm fairly new to python overall so maybe there is a simple thing I am missing.
This issue comes when there are multiple versions of python or any package you are running at current time. The same issue was with me too when the IDLE was not able to detect the position of where the package is installed.
My suggestion is that uninstall all the versions of python and the module you are using and install them again. Otherwise shift to any other IDLE, in my recommendation - Visual Studio Code.
In my terminal, I ran:
pip install pandas
pip3 install pandas
Installation seemed to go well. When I write some code in a file and execute it in my terminal (prompting 'python filename.py' or 'python3 filename.py'), the pandas library can be imported and used without a problem. However, when using Jupyter Lab and Jupyter Notebook, and I get this error when trying to import pandas:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-38d4b0363d82> in <module>
----> 1 import pandas
ModuleNotFoundError: No module named 'pandas'
It seems like Jupyter Notebook does not recognize this library. Very confused as of why and what I should do. FYI reinstalling anaconda did not help, and I am using 'pip' and 'pip3' to install libraries.
I had a similar problem. Your best bet is to install your packages direct from Jupyter notebook, then you can be sure that the packages are being installed into the local python instance.
! pip install --user <package>
The ! tells the notebook to execute the cell as a shell command.
you've got at least 3 versions of Python installed (the system version, a copy of 3.7 and 3.8). you need to figure out which is which, i.e. what you've done to your system!
to know which version of Python is being run you can use something like (from your shell/command prompt, not in Python):
which python3
see here for an explanation and alternatives. this tells you where some version of Python is, but you can also ask for pip3 and conda, jupyter, etc, to see where those have ended up, and to make sure you're running the right one. note that this involves your "shell's path" which you can customise so it picks the right one
next you need tools to figure out the equivalent "within Python". Python libraries aren't independent programs/executables (i.e. what $PATH determines) so this is a seperate set of options
to display where Python looks for code you can do this (inside Python):
import sys
print(sys.path)
see here for more info about what's going on here
note that what happens when you "open jupyter notebook by clicking on the icon with Anaconda Navigator" is a bit more difficult to debug. sys.executable might be useful to figure out what's going on
if you know xkcd, we're sort of in this state
I am trying to get Pandas to work on my Pycharm environment. I have installed it through the command:
pip install pandas
But when I run the code in my environment, import pandas as pd
I get the error:
No module named 'pandas'
When I try to install it using the project interpreter in Pycharm, I get the error:
error occurred when installing package 'pandas'
EDIT:
I didn't state what happens when I look into this error. I click 'Details'.
Then it says:
AttributeError: module 'pip' has no attribute 'main'
Perhaps this may tell us something about the issue
The error is identical to the one reported here Module pip has no attribute 'main'
For pip version 10.x and higher you should update Pycharm to 2018.2.
Or simply run pip in a terminal outside of Pycharm
Which Python version are you using? If you are using Python3, then the correct command is pip3 install pandas.
Make sure that the pip command you are calling refers to the same python that you are running. Try pip -V for more information.
-Update your pycharm to the latest version
-Update pip to the latest version and ensure its same as the python.exc
-Run pip install pandas command as an administrator
-Try installing pandas again
Apparently, you installed Pandas for python2 by pip. For python3, you need to use pip3.
However, it doesn't matter regarding your problem. Probably, you don't choose the right project interpreter.
For Pycharm, it supports the system python(2 and 3), as well as the virtual environment. You may install the Pandas module in system python, but use the virtual environment as default.
Simple solution
Make sure you select the interpreter you want (system or
virtualenv);
Check package list, if there is Pandas module;
If yes, refresh the project list;
If not, simply click + to search Pandas and install it to your
project interpreter.
I am new to python and I am trying to make a simple stock market program using pandas to import the data. I have installed Anaconda which said that it installed pandas along with it, as well as Python 2.7. I use PyCharm as my IDE. When I run:
import pandas as pd
from pandas_datareader import data
I receive the error message
import pandas as pd
ImportError: No module named pandas
I am not sure why it is giving me this error message so any help would be greatly appreciated
When entering the command to run your file, make sure you specify which version of python you're using. For example, instead of python filename.py, use python3 filename.py or python2 filename.py
Try to install it using sudo ...
sudo pip3 install pandas
for ubuntu ... it worked got me. pip or pip3 .. as per your requirement.
You need to pip install pandas and things will work.
Your issue is that pandas is not installed locally on your computer. Luckily, this is a simple task to accomplish by opening up either a Terminal or Command Prompt (depending on your OS), and typing in the command pip install pandas. This will install pandas and you will be good to go!
The issue is that Anaconda installs a Python version of its own, and likely the Python version is Python 3. When you use PyCharm IDE as your editor, you are using another version of Python (Python2). For my Mac, Anaconda's Python is installed under /anaconda3/bin and my default Python is installed under /usr/bin/python.
I recommend you either config PyCharm to use Anaconda's Python, or use Anaconda's Jupyter your project. Jupyter is arguably a stronger tool considering that you are doing data analytics task.
Also, for Anaconda's python, you shoud use conda install pandas instead of pip install pandas to install additional packages. This is not necessary this time since it's already installed.
I signed up for a statistics udemy course which uses jupyter running the stock numpy package out of anaconda.
Numpy is working when I run python 3.4.4 in pycharm, but it will not work in either anaconda2 nor anaconda3.. this makes no sense because numpy comes stock as part of the anaconda library.
When I try importing numpy in jupyter, running a local instance of a python 2 script, I get this:
Thinking I could sidestep the error using a IDE, I tried pycharm and I got this:
Numpy is part of the anaconda default library which I'm running, so I checked and made sure the numpy package was there via the Anaconda Prompt using 'conda list'...
Why won't it import successfully?
Before I uninstall and reinstall everything, does anyone have any ideas?
Yayyyy. I figured it out. So I had several different python versions before I was running python through anaconda/jupyter. As a result, the tethering in-between the additional package libraries to the version of python running was shifty. For example, I may have had numpy working configured to 3.4 but not 2.7..
anyways, to break down the steps I took, I uninstalled all instances of python (both anaconda and normal versions). Then I deleted the old 3.4 libraries from my C drive. Then I installed anaconda 2.7.11 again, tested importing numpy and got the same error. Then I thought to myself, what if the packages are installed separate from the python library and their configuration didn't get reset via the reinstall.. so via the anaconda prompt I typed:
pip uninstall numpy
which removed the package I was having trouble with. and then :
pip install numpy
which downloaded and reset a whole new instance of the package. Then I tested importing numpy in both the anaconda prompt and jupyter = both worked.
I'm very happy that this ended up working out as I can continue on as planned. For anyone else who experiences a similar problem, I would try uninstalling, then reinstalling the problem causing package via pip commands - this step seemed to have the most impact on fixing the problem. Then if that doesn't work proceed to uninstall and reinstall the environments in intervals.
You can try using the following command:
pip install numpy --upgrade
This will uninstall old installed version of numpy and install a new version. This command solved my issue.
try activating you base conda environment before starting jupyter.
>activate root
>jupyter notebook