Trying to install Pandas for Python - python

I can't seem to install Pandas for Python on my Macbook. I have gone through different threads to try to understand but have not been able to find a solution.
i have used pip install pandas
The Error i get:
xxx-MacBook-Pro:~ edss$ pip install pandas
Collecting pandas
Using cached pandas-0.22.0-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
Requirement already satisfied: python-dateutil in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from pandas)
Collecting numpy>=1.9.0 (from pandas)
Using cached numpy-1.14.2-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
Requirement already satisfied: pytz>=2011k in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from pandas)
Installing collected packages: numpy, pandas
Found existing installation: numpy 1.8.0rc1
DEPRECATION: Uninstalling a distutils installed project (numpy) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
Uninstalling numpy-1.8.0rc1:
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py", line 342, in run
prefix=options.prefix_path,
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py", line 778, in install
requirement.uninstall(auto_confirm=True)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 754, in uninstall
paths_to_remove.remove(auto_confirm)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_uninstall.py", line 115, in remove
renames(path, new_path)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/utils/__init__.py", line 267, in renames
shutil.move(old, new)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 302, in move
copy2(src, real_dst)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 131, in copy2
copystat(src, dst)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 103, in copystat
os.chflags(dst, st.st_flags)
OSError: [Errno 1] Operation not permitted: '/var/folders/km/5sv3zt816sl74rb9qcmt0vr40000gn/T/pip-LvWuDt-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy-1.8.0rc1-py2.7.egg-info'
UPDATE -----!!
I found that I could just download Anaconda and use Spyder.
Thanks for the help guys!

I disagree with the answers saying to use sudo pip install to get around permissions errors. This is not always a safe approach. On OSX, you should be able to get around your current error using the --user flag.
So:
pip install --user pandas
However, as #Kasramvd has noted in the comments, one of the safest options is to use a virtual environment.
Not saying that using sudo is bad, just that you should understand what you are doing when you use it.
From What are the risks of running 'sudo pip'?:
When you run pip with sudo, you run setup.py with sudo. In other words, you run arbitrary Python code from the Internet as root. If someone puts up a malicious project on PyPI and you install it, you give an attacker root access to your machine. Prior to some recent fixes to pip and PyPI, an attacker could also run a man in the middle attack to inject their code when you download a trustworthy project.
(That answer may be somewhat dated, but the first part holds true)

try to run wih sudo
if you want to know why you get this problem check this stackoverflow answer

Pip is highly unreliable. Try download the source and compiling it. That almost always works.
As suggested above. Try it with Sudo first. It looks like that is blocking your pip install attempt.

Related

Error in installing scikit-learn in ubuntu

When is try to install scikit learn, im getting this error,
I used "pip install -U scikit-learn[alldeps]"
"""Collecting scikit-learn[alldeps]
Using cached scikit_learn-0.18.1-cp27-cp27mu-manylinux1_x86_64.whl
Requirement already up-to-date: numpy>=1.6.1; extra == "alldeps" in /usr/local/lib/python2.7/dist-packages (from scikit-learn[alldeps])
Collecting scipy>=0.9; extra == "alldeps" (from scikit-learn[alldeps])
Using cached scipy-0.19.0-cp27-cp27mu-manylinux1_x86_64.whl
Installing collected packages: scipy, scikit-learn
Found existing installation: scipy 0.17.0
DEPRECATION: Uninstalling a distutils installed project (scipy) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
Uninstalling scipy-0.17.0:
Exception:
Traceback (most recent call last):
File "/home/suba/.local/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/home/suba/.local/lib/python2.7/site-packages/pip/commands/install.py", line 342, in run
prefix=options.prefix_path,
File "/home/suba/.local/lib/python2.7/site-packages/pip/req/req_set.py", line 778, in install
requirement.uninstall(auto_confirm=True)
File "/home/suba/.local/lib/python2.7/site-packages/pip/req/req_install.py", line 754, in uninstall
paths_to_remove.remove(auto_confirm)
File "/home/suba/.local/lib/python2.7/site-packages/pip/req/req_uninstall.py", line 115, in remove
renames(path, new_path)
File "/home/suba/.local/lib/python2.7/site-packages/pip/utils/__init__.py", line 267, in renames
shutil.move(old, new)
File "/usr/lib/python2.7/shutil.py", line 303, in move
os.unlink(src)
OSError: [Errno 13] Permission denied: '/usr/lib/python2.7/dist-packages/scipy-0.17.0.egg-info' """
How can i fix this error?
Permission error.
sudo pip install -U scikit-learn[alldeps] could help.
There's a permission error. Are you using root permissions to install? If not, please use same command prefixed with 'sudo' and provide password when asked.

Clean workaround for Pip issues under PyCharm that won't entail direct CLI access

I'd like to be able to document how to add a package to a VirtualEnv under Python 3.6 in PyCharm.
“Unable to locate finder for 'pip._vendor.distlib'” error when using "pip install virtualenv" , for one example, articulates what appears to be the same basic issue, a known issue with current PyCharm, resolved by command line commands.
I like the LUM CLI and it is like a native language to me, but I am trying to document things clearly for developers who may or may not be comfortable with any Unix-like CLI, and the instructions in the question above ask people to resolve the matter through the CLI.
Is there any way either to fix the Pip issues from within PyCharm as IDE, or to attach a project to a VirtualEnv and install a package represented on PyPI?
The error message I'm getting (for the curious) is:
Collecting bleach
Downloading bleach-2.0.0-py2.py3-none-any.whl
Collecting html5lib>=0.99999999 (from bleach)
Downloading html5lib-0.999999999-py2.py3-none-any.whl (112kB)
Collecting six (from bleach)
Downloading six-1.10.0-py2.py3-none-any.whl
Collecting setuptools>=18.5 (from html5lib>=0.99999999->bleach)
Downloading setuptools-34.3.2-py2.py3-none-any.whl (389kB)
Collecting webencodings (from html5lib>=0.99999999->bleach)
Downloading webencodings-0.5.tar.gz
Collecting appdirs>=1.4.0 (from setuptools>=18.5->html5lib>=0.99999999->bleach)
Downloading appdirs-1.4.3-py2.py3-none-any.whl
Collecting packaging>=16.8 (from setuptools>=18.5->html5lib>=0.99999999->bleach)
Downloading packaging-16.8-py2.py3-none-any.whl
Collecting pyparsing (from packaging>=16.8->setuptools>=18.5->html5lib>=0.99999999->bleach)
Downloading pyparsing-2.2.0-py2.py3-none-any.whl (56kB)
Installing collected packages: six, appdirs, pyparsing, packaging, setuptools, webencodings, html5lib, bleach
Found existing installation: setuptools 18.1
Uninstalling setuptools-18.1:
Successfully uninstalled setuptools-18.1
Rolling back uninstall of setuptools
You are using pip version 7.1.0, however version 9.0.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
Exception:
Traceback (most recent call last):
File "C:\Users\CJSHa\cardshopenv\lib\site-packages\pip-7.1.0-py3.6.egg\pip\basecommand.py", line 223, in main
status = self.run(options, args)
File "C:\Users\CJSHa\cardshopenv\lib\site-packages\pip-7.1.0-py3.6.egg\pip\commands\install.py", line 299, in run
root=options.root_path,
File "C:\Users\CJSHa\cardshopenv\lib\site-packages\pip-7.1.0-py3.6.egg\pip\req\req_set.py", line 646, in install
**kwargs
File "C:\Users\CJSHa\cardshopenv\lib\site-packages\pip-7.1.0-py3.6.egg\pip\req\req_install.py", line 813, in install
self.move_wheel_files(self.source_dir, root=root)
File "C:\Users\CJSHa\cardshopenv\lib\site-packages\pip-7.1.0-py3.6.egg\pip\req\req_install.py", line 1008, in move_wheel_files
isolated=self.isolated,
File "C:\Users\CJSHa\cardshopenv\lib\site-packages\pip-7.1.0-py3.6.egg\pip\wheel.py", line 465, in move_wheel_files
generated.extend(maker.make(spec))
File "C:\Users\CJSHa\cardshopenv\lib\site-packages\pip-7.1.0-py3.6.egg\pip\_vendor\distlib\scripts.py", line 323, in make
self._make_script(entry, filenames, options=options)
File "C:\Users\CJSHa\cardshopenv\lib\site-packages\pip-7.1.0-py3.6.egg\pip\_vendor\distlib\scripts.py", line 227, in _make_script
self._write_script(scriptnames, shebang, script, filenames, ext)
File "C:\Users\CJSHa\cardshopenv\lib\site-packages\pip-7.1.0-py3.6.egg\pip\_vendor\distlib\scripts.py", line 163, in _write_script
launcher = self._get_launcher('t')
File "C:\Users\CJSHa\cardshopenv\lib\site-packages\pip-7.1.0-py3.6.egg\pip\_vendor\distlib\scripts.py", line 302, in _get_launcher
result = finder(distlib_package).find(name).bytes
File "C:\Users\CJSHa\cardshopenv\lib\site-packages\pip-7.1.0-py3.6.egg\pip\_vendor\distlib\resources.py", line 297, in finder
raise DistlibException('Unable to locate finder for %r' % package)
pip._vendor.distlib.DistlibException: Unable to locate finder for 'pip._vendor.distlib'
From PyCharm docs, regarding pip:
PyCharm provides a dedicated tool for installing, uninstalling, and
upgrading Python packages. So doing, if a packaging tool is missing,
PyCharm suggests to install it.
And regarding virtualenv:
PyCharm makes it possible create virtual environment using the
virtualenv tool. So doing, PyCharm tightly integrates with virtualenv,
and enables configuring virtual environments right in the IDE.

Install tweepy module with pip

I'm relatively new to coding but feel like I have a firm understanding of the basics. I am looking to use python to experiment with twitter using the tweepy module but I'm having trouble install it, and other modules too, using pip in the command line.
Typing pip pip install tweepy into the command line (Terminal on macOS Sierra) returns the string of errors at the end of this post.
If anyone could shed any light onto why I can't install any modules I would very much appreciate it.
Thanks in advance.
Collecting tweepy
Using cached tweepy-3.5.0-py2.py3-none-any.whl
Collecting six>=1.7.3 (from tweepy)
Using cached six-1.10.0-py2.py3-none-any.whl
Collecting requests-oauthlib>=0.4.1 (from tweepy)
Using cached requests_oauthlib-0.7.0-py2.py3-none-any.whl
Collecting requests>=2.4.3 (from tweepy)
Using cached requests-2.11.1-py2.py3-none-any.whl
Collecting oauthlib>=0.6.2 (from requests-oauthlib>=0.4.1->tweepy)
Using cached oauthlib-2.0.0.tar.gz
Installing collected packages: six, oauthlib, requests, requests-oauthlib, tweepy
Found existing installation: six 1.4.1
DEPRECATION: Uninstalling a distutils installed project (six) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
Uninstalling six-1.4.1:
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py", line 342, in run
prefix=options.prefix_path,
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py", line 778, in install
requirement.uninstall(auto_confirm=True)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 754, in uninstall
paths_to_remove.remove(auto_confirm)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_uninstall.py", line 115, in remove
renames(path, new_path)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/utils/__init__.py", line 267, in renames
shutil.move(old, new)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 302, in move
copy2(src, real_dst)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 131, in copy2
copystat(src, dst)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 103, in copystat
os.chflags(dst, st.st_flags)
OSError: [Errno 1] Operation not permitted: '/var/folders/3m/f0y775rj4nj_xc8t0vntyjk80000gn/T/pip-thDOd4-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info'
As mentioned above, you need root access where pip stores the packages.
Python 3.x:
sudo pip3 install tweepy
Python 2.x:
sudo pip install tweepy
You may also use Git to clone the repository from Github and install it manually:
git clone https://github.com/tweepy/tweepy.git
cd tweepy
python setup.py install
Alternatively you can use virtualenv
"What if you can't install packages into the global site-packages directory? For instance, on a shared host.
In all these cases, virtualenv can help you. It creates an environment that has its own installation directories, that doesn't share libraries with other virtualenv environments (and optionally doesn't access the globally installed libraries either)."
Basically it's allow you to create an isolated environment for each of your project and it's help on permission issue you have.
For more information:
Installing Python on Mac OS X: virtualenv
Operation not permitted
You need to run:
sudo pip install tweepy
You have problems with permissions. As suggested above, you can try to use sudo

Using PIP to download a Python Package. Permission error

I'm using PIP to get a package I need for Python but I'm getting a permission error even when I'm using "sudo" to access the package.
I'm following the instructions posted here on the website for the package.
sudo pip install -U nltk
Password:
The directory '/Users/me/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/me/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting nltk
Downloading nltk-3.0.5.tar.gz (1.0MB)
100% |████████████████████████████████| 1.0MB 289kB/s
Collecting six>=1.9.0 (from nltk)
Downloading six-1.9.0-py2.py3-none-any.whl
Installing collected packages: six, nltk
Found existing installation: six 1.4.1
DEPRECATION: Uninstalling a distutils installed project (six) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
Uninstalling six-1.4.1:
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/basecommand.py", line 211, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/commands/install.py", line 311, in run
root=options.root_path,
File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/req/req_set.py", line 640, in install
requirement.uninstall(auto_confirm=True)
File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/req/req_install.py", line 716, in uninstall
paths_to_remove.remove(auto_confirm)
File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/req/req_uninstall.py", line 125, in remove
renames(path, new_path)
File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/utils/__init__.py", line 315, in renames
shutil.move(old, new)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 302, in move
copy2(src, real_dst)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 131, in copy2
copystat(src, dst)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 103, in copystat
os.chflags(dst, st.st_flags)
OSError: [Errno 1] Operation not permitted: '/tmp/pip-KICJWB-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info'
It says my parent directory is not owned by me ... but I'm the only user on my computer. So I don't know what is going on here.
Thanks,
Got very similar issue while trying to install awscli. Following worked for me. Just changing the package name. You can try -
sudo -H pip install nltk --upgrade --ignore-installed six

Installing praw on a mac

I have already installed homebrew and pip. When I run $pip install praw the following comes up:
dhcp-215-185:~ my_name$ pip install praw
Downloading/unpacking praw
Downloading praw-2.1.16-py2.py3-none-any.whl (70kB): 70kB downloaded
Downloading/unpacking update-checker>=0.10 (from praw)
Downloading update_checker-0.10-py2.py3-none-any.whl
Downloading/unpacking requests>=1.2.0 (from praw)
Downloading requests-2.2.1-py2.py3-none-any.whl (625kB): 625kB downloaded
Downloading/unpacking six>=1.4 (from praw)
Downloading six-1.6.1-py2.py3-none-any.whl
Installing collected packages: praw, update-checker, requests, six
Cleaning up...
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-1.5.5-py2.7.egg/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip-1.5.5-py2.7.egg/pip/commands/install.py", line 283, in run
requirement_set.install(install_options, global_options, root=options.root_path)
File "/Library/Python/2.7/site-packages/pip-1.5.5-py2.7.egg/pip/req.py", line 1435, in install
requirement.install(install_options, global_options, *args, **kwargs)
File "/Library/Python/2.7/site-packages/pip-1.5.5-py2.7.egg/pip/req.py", line 671, in install
self.move_wheel_files(self.source_dir, root=root)
File "/Library/Python/2.7/site-packages/pip-1.5.5-py2.7.egg/pip/req.py", line 901, in move_wheel_files
pycompile=self.pycompile,
File "/Library/Python/2.7/site-packages/pip-1.5.5-py2.7.egg/pip/wheel.py", line 215, in move_wheel_files
clobber(source, lib_dir, True)
File "/Library/Python/2.7/site-packages/pip-1.5.5-py2.7.egg/pip/wheel.py", line 205, in clobber
os.makedirs(destdir)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/praw'
Storing debug log for failure in /Users/my_name/Library/Logs/pip.log
dhcp-215-185:~ my_name$
Does anyone have a fix? Installing this has been a real headache. Thanks a lot!
A quick workaround would be to use the sudo pip install praw command to intall praw as a super-user. However, this is not recommended, as it can cause problems later on with things such as updates and scaling your application upwards. One would instead suggest that you create a virtual environment, and pip install praw inside it.
If you are confident that the application you are building will not grow too large, it is probably ok to install praw using sudo.
I was getting the same error as you and I found an answer in the reddit documentation for PRAW. I used HomeBrew to install pip and I'm using Python 3.x instead of the 2.7x that's shipped with OSX, which means I needed to use pip3 instead of pip. It worked right away.
I hope this helps!

Categories

Resources