Can't import pandas although Its installed (module not found) MBP - python

Hi Guys I've been searching for more than two hours by now. I searched all over SOF and Youtube but found no answer.
I Have anaconda installed and as they said on the installing instructions pandas and other diferente pakgs are included already, but when I try to import pandas as pd on Jupyer or VS I get the module not found error.
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-7dd3504c366f> in <module>
----> 1 import pandas as pd
ModuleNotFoundError: No module named 'pandas'*
I only have python 3.8 installed no other versions. And I've confirmed several times that pandas is installed.
SHOW PANDAS AT TERMINAL
(base) Rogers-MBP:~ rogerrendon$ pip show pandas
Name: pandas
Version: 1.0.5
Summary: Powerful data structures for data analysis, time series, and statistics
Home-page: https://pandas.pydata.org
Author: None
Author-email: None
License: BSD
Location: /Users/rogerrendon/opt/anaconda3/lib/python3.8/site-packages
Requires: python-dateutil, numpy, pytz
Required-by: statsmodels, seaborn
PYTHON VERSION
(base) Rogers-MBP:~ rogerrendon$ python
Python 3.8.3 (default, Jul 2 2020, 11:26:31)
[Clang 10.0.0 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
PIP3 INSTALL CHECK
pip3 install pandas
Requirement already satisfied: pandas in ./opt/anaconda3/lib/python3.8/site-packages (1.0.5)
Requirement already satisfied: python-dateutil>=2.6.1 in ./opt/anaconda3/lib/python3.8/site-packages (from pandas) (2.8.1)
Requirement already satisfied: pytz>=2017.2 in ./opt/anaconda3/lib/python3.8/site-packages (from pandas) (2020.1)
Requirement already satisfied: numpy>=1.13.3 in ./opt/anaconda3/lib/python3.8/site-packages (from pandas) (1.18.5)
Requirement already satisfied: six>=1.5 in ./opt/anaconda3/lib/python3.8/site-packages (from python-dateutil>=2.6.1->pandas) (1.15.0)
Can please somebody help me? I'm loosing my mind hahah

You are using the built-in python from apple instead of Anaconda. During installation there is supposed to be a prompt that asks you something to the effect of "do you want anaconda to be your default python installation". If this didn't come up or you clicked past it too fast, it will not have made any changes to your bash profile (zsh on catalina) that would make your system aware of the new python installation. Some things (like pip) may use other ways to discover the correct distribution to target which is why that seems to find anaconda just fine.
If you open up your user folder and make hidden files visible (cmd shift period), you should find either bash or zsh profile files that control the startup of any system shell you call. If you don't find somewhere in those files a block put in there by the installer (it should be very clear from the comments), then effectively anaconda was installed, but never activated. Try opening a command prompt and calling:
(base) Rogers-MBP:~ rogerrendon$ source /Users/rogerrendon/opt/anaconda3/bin/activate
then if you are running 10.14 or earlier:
(base) Rogers-MBP:~ rogerrendon$ conda init
or if you have Catalina (10.15)
(base) Rogers-MBP:~ rogerrendon$ conda init zsh

I have dealt with similar issues in the past. The first thing to check is to make sure that you don't have multiple python versions installed throughout your computer (unless you require this). If you properly installed anaconda then you should have python within that environment. To uninstall other pythons, go to your uninstall apps page and find the python versions if they exist and remove them.
If after doing this an issue still arises, restart and check your path. Make sure you have paths to ...\anaconda3\Library\usr\bin, ...\anaconda3\Library\bin, and ...\anaconda3\Scripts
Another thing to try is conda installing pandas although anaconda should include this package already.
I've found an issue using hydrogen within Atom (basically allows jupyter to be used in Atom) where the atom search paths set from install are to the wrong package locations. Fixing this could become cumbersome so I would recommend the nuclear option of uninstalling everything and reinstalling if nothing above works.

Go to File->Setting->Project Interpreter->click on plus sign->type 'pandas'->Install Package.

Related

Getting : No module named 'clr' after changing python version

I had python 3.7.7 32bit installed on my laptop. I installed pip and pythonnet.
I have this line of code in my python project which is executing fine.
import sys, os, clr, time
from pathlib import Path
Now I have installed python 3.7.7 64bit version on my laptop. Before running the application, I changed the current python environment to point to 64bit. Upon changing the env, I'm getting the error :
No module named 'clr'
Do I have install pythonnet again for 64bit. If yes, how to do it again? Because when I try to install again it says
Requirement already satisfied: pythonnet in
c:\users\XXXXXX\appdata\local\programs\python\python37-32\lib\site-packages
(2.5.2) Requirement already satisfied: pycparser in
c:\users\XXXXXX\appdata\local\programs\python\python37-32\lib\site-packages
(from pythonnet) (2.21)
It is referring to python37-32 still. How do I target it to python37 (64bit).
I have stumbled into this issue a lot with my classmates in programming classes. The problem is that different programs point to different versions of Python. Assuming you're using VS Code, you are able to change which Python version to use, by the "Python: Select Interpreter" command.
Assuming you're using the terminal, you can change which Python version to use when you type "python", by changing your PATH environments.

Selenium "No module named 'selenium' " even after pip3 install

I do not know why I cannot import selenium even after I pip install it.
Does anyone know how else I can troubleshoot it or how to fix this?
I am using Mac OS and python 3.7.4
python3
Python 3.7.4
Type "help", "copyright", "credits" or "license" for more information.
>>> import selenium
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'selenium'
>>>
pip3 install selenium
Requirement already satisfied: selenium in /usr/local/lib/python3.7/site-packages
Requirement already satisfied: urllib3 in /usr/local/lib/python3.7/site-packages (from selenium)
UPDATE
I was kind of messing around and one of the things that I did helped make it work. I am not sure which of the items but if someone can explain it so I understand this in the future, that would be appreciated.
I did brew doctor which outputted the following
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!
Warning: A newer Command Line Tools release is available.
Update them from Software Update in System Preferences or
https://developer.apple.com/download/more/.
Warning: You have unlinked kegs in your Cellar.
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
python
brew link --overwrite python
vi /usr/local/bin/pip
and changed /usr/local/opt/python/bin/python3.7 to /usr/local/opt/python/bin/python3 and it worked
I am guessing my issue is that I have two instances of python installed so it was downloading the selenium library to a difference python version (3.7) instead of 3 which is what I wanted.
Let me know if you think this was the issue or if you can clarify what you may think is the issue
try pip install, instead of pip3
Please check the pip version using command
pip --version
Mostly, pip is associated with python version 2.7 while pip3 is associated with python3
So, try -
pip3 install selenium
Since pip will install it for python2 while pip3 will install for python3 as you are using python3 in the question.

pip3, python does nothing on Windows cmd

Yes, I already read that question but it didn't help me.
C:\Users\*\Documents\git-workspace\redditCountdownGui>"C:\Program Files\WPy64-3741\python-3.7.4.amd64\Scripts\pyinstaller.exe"
C:\Users\*\Documents\git-workspace\redditCountdownGui>
I tried using this method:
C:\Users\*\Documents\git-workspace\redditCountdownGui>"C:\Program Files\WPy64-3741\python-3.7.4.amd64\python.exe" -m pyinstaller
C:\Program Files\WPy64-3741\python-3.7.4.amd64\python.exe: No module named pyinstaller
C:\Users\*\Documents\git-workspace\redditCountdownGui>
I can't get it to work. It's also not working for pip:
C:\Users\*\Documents\git-workspace\redditCountdownGui>"C:\Program Files\WPy64-3741\python-3.7.4.amd64\Scripts\pip.exe"
C:\Users\*\Documents\git-workspace\redditCountdownGui>"C:\Program Files\WPy64-3741\python-3.7.4.amd64\Scripts\pip3.exe"
C:\Users\*\Documents\git-workspace\redditCountdownGui>
I also tried adding to PATH but then it's the same - no output at all.
Can anyone help me?
When using WinPython, you need to start WinPython Command Prompt to get all Paths set correctly. Within that shell, you can use pip as usual:
D:\WPy64-3740\scripts>python
Python 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 20:34:20) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.executable
'D:\\WPy64-3740\\python-3.7.4.amd64\\python.exe'
>>> exit()
D:\WPy64-3740\scripts>python -m pip install requests
Requirement already satisfied: requests in d:\wpy64-3740\python-3.7.4.amd64\lib\site-packages (2.22.0)
Requirement already satisfied: certifi in d:\wpy64-3740\python-3.7.4.amd64\lib\site-packages (from requests) (2019.6.16)
Requirement already satisfied: urllib3 in d:\wpy64-3740\python-3.7.4.amd64\lib\site-packages (from requests) (1.25.3)
Requirement already satisfied: chardet in d:\wpy64-3740\python-3.7.4.amd64\lib\site-packages (from requests) (3.0.4)
Requirement already satisfied: idna in d:\wpy64-3740\python-3.7.4.amd64\lib\site-packages (from requests) (2.8)
D:\WPy64-3740\scripts>
I know it's a lazy answer, but this is Windoze. You should simply uninstall and reinstall Python.
During the install, the python executable should get added to the paths correctly ...although (depending on installer) you may need to specifically select a checkbox to add it to the system paths. It should also install pip, although (again) you may need to specifically select that in a checkbox during install.
After (proper) installation, you should be able to open a cmd window, and simply type python and be dropped into the Python working environment. You should also be able to just type pip and find the working copy of pip.
If you can't do this, your Windows environment has gotten screwed up :/
Please note, if you have more than one version of Python installed, you may need to type python3 / pip3 to access the correct version.
The error message No module named pyinstaller is because the Python can't find your site-packages. This is also a result of your paths being screwed up when you're calling python.
Try running the command python -m site to see where your site-packages is installed, ensure it is in your paths, and ensure that the module in question is installed there.
Different versions of Python have their own paths for site-packages. So installing a module for Python 2.7 does not install it for Python 3.x

Unable to import praw module after install

Edit: Before you start deleting/modifying installs, please glance over StvnW's answer/summary to make sure you are applying the solution that is appropriate for you.
I've installed python 2.7.5 and pip [edit: mac OSX Mountain Lion.] I've run "pip install praw" in terminal. All good. When I run python and run "import praw" I get:
...$ python
Python 2.7.5 (v2.7.5:ab05e7dd2788, May 13 2013, 13:18:45)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import praw
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named praw
...same ImportError from a script.
when I install praw I get this:
$ pip install praw
Downloading/unpacking praw
Downloading praw-2.1.10.tar.gz (83kB): 83kB downloaded
Running setup.py egg_info for package praw
Requirement already satisfied (use --upgrade to upgrade): requests>=1.2.0 in
/usr/local/lib/python2.7/site-packages (from praw)
Requirement already satisfied (use --upgrade to upgrade): six in
/usr/local/lib/python2.7/site-packages (from praw)
Requirement already satisfied (use --upgrade to upgrade): update-checker>=0.6 in
/usr/local/lib/python2.7/site-packages (from praw)
Requirement already satisfied (use --upgrade to upgrade): setuptools in
/usr/local/lib/python2.7/site-packages/setuptools-1.1.6-py2.7.egg (from update-
checker>=0.6->praw)
Installing collected packages: praw
Running setup.py install for praw
Installing praw-multiprocess script to /usr/local/bin
Successfully installed praw
Cleaning up...
In python if I run help('modules') it isn't there.
Relatively new to python and I haven't been able to sort this out with google search. Any hints would be much appreciated.
Edit:
SitRep:
I've uninstalled 2.7.2, uninstalled praw, and uninstalled (homebrew) pip. I ran python 2.7.5 and it couldn't find the module (as you would suspect.) I then reinstalled pip with easy_install and now 2.7.5 is finding praw but giving this error:
$ python
Python 2.7.5 (v2.7.5:ab05e7dd2788, May 13 2013, 13:18:45)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import praw
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/praw/__init__.py", line 43, in <module>
from update_checker import update_check
File "/Library/Python/2.7/site-packages/update_checker.py", line 11, in <module>
from pkg_resources import parse_version as V
ImportError: No module named pkg_resources
>>>
Thanks for the help so far, the spurious install was the root of problem 1.
The solution to the final problem can be found here:
No module named pkg_resources
I wish there were some way to summarize this for future readers, but I've done so many things that I no longer recall what addressed what. I basically uninstalled everything (python 2.7.2, 2.7.5, praw, pip,) reinstalled 2.7.5 from http://python.org/download/, reinstalled pip with easy_install (and sudo command) instead of homebrew, reinstalled praw with sudo command, and followed the directions for the subsequent module error in the link above. Hope that helps. :)
The OS X system versions of Python live in /System/Library/Frameworks/Python.Framework/<verson>, each of which links to /Library/Python/<version>/site-packages. Seems like you have installed another version of python and/or pip to /usr/local, but when you invoke python you are still getting the system version.
Try this:
$ /usr/local/bin/python
>>> import praw
I'd also recommend looking into tools like pyenv and virtualenv if you are going to do any amount of work with Python. Pyenv lets you easily manage and switch between multiple versions (including micro versions x.x.3, x.x.5, etc). Virtualenv lets you create isolated Python environments where you can pin down versions of site-packages specific to a particular project.
Edit (summarizing):
sudo easy_install pip will install pip under /System/Library/Python/<version>. Calling that pip will install packages to /Library/Python/<version>/site-packages
brew install python will install a second version of python — including pip — under /usr/local/. That pip will put packages in /usr/local/lib/python<version>/site-packages/`.
One version may not see packages installed to the other.
which python and which pip are helpful for troubleshooting.
Dean's final solution above results in user packages being installed to the system site-packages.
Despite Dean's choice to update the system Python, many would advocate instead using brew, pyenv, and virtualenv to isolate oneself from the system Python.
It's strange. I am suspecting you have another version of python2.7 on your mac os
If you are using a mac. Check the version of python on your shell's path using which python. Then make sure that the shebang line in the script you are trying to run uses the same version of python.
In my terminal I typed
which python and got the output /usr/local/bin/python
I went to the script I was trying to run and added the following to the first line
#!/usr/local/bin/python
Then I went back to my terminal. Checked that I was in the same directory as the script I wanted to run and typed
./my_script.py
If you don't see any output at this point make sure that you have execution permission enabled for your script by typing chmod +x my_script.py in ther terminal. Then try running the script again using ./my_script.py

Can not install pandas on windows 64 bit

Trying to install pandas on a new windows 64 system. I did so using:
pip install pandas
the installtion aborts with error when trying to install pytz (from pandas):
Could not find a version that satisfies the requirement pytz (from pandas)
Trying to import pandas falis with error:
Cannot import name hashtable
How can I over come it? Or should I just install the 32 bit version of pandas?
I used to have a lot of installation issues when I tried to manually create my own Python environment. I run Windows 7 64-bit and would suggest you download and try to install any one of these:
https://store.continuum.io/cshop/anaconda/
https://code.google.com/p/pythonxy/
If you're running CPython you can try to install it using the windows binaries available here: http://www.lfd.uci.edu/~gohlke/pythonlibs/#pandas
You can find several binaries, for different Python version and x64/win32. It also has a link to it's dependencies (like pytz) if you don't have them all.
My complete windows Python environment was built based on that.

Categories