I installed Pillow using Anaconda but if I cannot load the module (see below). How coudl I fix this?
dhcp-86-216:Python_code Alberto$ pip install Pillow
Requirement already satisfied (use --upgrade to upgrade): Pillow in /Users/Alberto/anaconda/lib/python2.7/site-packages
Cleaning up...
dhcp-86-216:Python_code Alberto$ python
Python 2.7.6 (v2.7.6:3a1db0d2747e, Nov 10 2013, 00:42:54)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import Pillow
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named Pillow
Import PIL, not Pillow:
import PIL
Related
Actually I already installed tensorflow by using
$ pip install tensorflow
and it works well when I use
$ python
Python 2.7.15 (default, Jul 23 2018, 21:27:06)
[GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>import tensorflow
>>>
but when I use python3 on command line
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 26 2018, 23:26:24)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'tensorflow'
>>>
it shows an error, and it shows the same error when I use IDLE
use
pip3 install tensorflow
pip installs to default python directory. pip3 installs to python3
Python newbie here.
I'm trying to do a scraper in Python3, but I'm having problems importing lxml on my Sierra 10.12.
Here's the process and additional info:
$ python3 --version
Python 3.5.1
$ pip3 install lxml
Requirement already satisfied: lxml in /usr/local/lib/python3.6/site-packages
$ python3
Python 3.5.1 (v3.5.1:37a07cee5969, Dec 5 2015, 21:12:44)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import lxml
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'lxml'
>>>
Am I doing something wrong? Is there any other way to install a module?
I noticed that lxml seems to be installed on python 3.6 folder, even though my python3 version is 3.5.1, is that what's wrong?
EDIT: I tried the same thing with python 2.7 and got the same result.
$ python --version
Python 2.7.10
$ pip install lxml
Requirement already satisfied: lxml in /usr/local/lib/python2.7/site-packages
$ python2.7
Python 2.7.10 (default, Feb 7 2017, 00:08:15)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import lxml
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'lxml'
>>>
I installed scikit-learn as well as numpy and scipy with conda for python 3.6. But I am not able to import sklearn in python3.6. What is wrong and how can I fix it?
Here is what I see in conda list:
numpy 1.12.1 py36_0
scipy 0.19.0 np112py36_0
scikit-learn 0.19.0 np112py36_0
And here is the error message I got trying to import sklearn:
Python 3.6.0 (v3.6.0:41df79263a11, Dec 22 2016, 17:23:13)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sklearn
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'sklearn'
I'm using OS X and conda 4.3.24.
I'm trying to get this Python 2.7 code to work.
https://github.com/slanglab/phrasemachine
I've downloaded and unzipped the repo from github. Here's what happens when I try to run the code.
phrasemachine$ python
Python 2.7.10 (default, Oct 23 2015, 19:19:21)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import phrasemachine
>>> text = "Barack Obama supports expanding social security."
>>> print phrasemachine.get_phrases(text)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "phrasemachine.py", line 253, in get_phrases
tagger = TAGGER_NAMES[tagger]()
File "phrasemachine.py", line 166, in get_stdeng_nltk_tagger
tagger = NLTKTagger()
File "phrasemachine.py", line 133, in __init__
import nltk
ImportError: No module named nltk
So, I need the nltk module. I have that installed here:
Sure enough, Python 2 doesn't know about nltk.
phrasemachine$ python
Python 2.7.10 (default, Oct 23 2015, 19:19:21)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import nltk
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named nltk
But, Python 3 does.
phrasemachine$ python3
Python 3.5.1 (v3.5.1:37a07cee5969, Dec 5 2015, 21:12:44)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import nltk
>>>
Pip tells me that nltk is already installed, but for 3.5.
$ sudo pip install -U nltk
Requirement already up-to-date: nltk in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/nltk-3.2.1-py3.5.egg
Update 10/10/16: I installed the 2.7 version of Python via brew, which give me the 2.7 pip.
$ /usr/local/bin/pip --version
pip 8.1.2 from /usr/local/lib/python2.7/site-packages (python 2.7)
Then I installed nltk with that pip:
$ sudo /usr/local/bin/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.2.1.tar.gz (1.1MB)
100% |████████████████████████████████| 1.1MB 683kB/s
Installing collected packages: nltk
Running setup.py install for nltk ... done
Successfully installed nltk-3.2.1
It says it installed nltk but the warnings are concerning. And, Python 2.7 still fails to import nltk.
$ python
Python 2.7.10 (default, Oct 23 2015, 19:19:21)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import phrasemachine
>>> text = "Barack Obama supports expanding social security."
>>> print phrasemachine.get_phrases(text)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "phrasemachine.py", line 253, in get_phrases
tagger = TAGGER_NAMES[tagger]()
File "phrasemachine.py", line 166, in get_stdeng_nltk_tagger
tagger = NLTKTagger()
File "phrasemachine.py", line 133, in __init__
import nltk
ImportError: No module named nltk
>>> import nltk
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named nltk
Final update! I pointed Python 2.7 to the site packages directory where Homebrew installs stuff and I'm now good!
>>> import sys
>>> sys.path.append('/usr/local/lib/python2.7/site-packages')
Since you have two python distributions, you also need two versions of pip. Find out where your pip executables are with which -a pip, and install pip for your Python 2.7 distribution if necessary. Then tell the pip that goes with Python 2.7 (perhaps /usr/local/bin/pip) to install the nltk.
(Edit: Pip must be able to find the proper Python on its PATH. I hadn't thought to go into this.)
I am am following these instructions exactly to install and run django-enumfields. But as you can see below, it is not working. Has anyone else gotten this module to work?
$ sudo pip install django-enumfield
Downloading/unpacking django-enumfield
Downloading django-enumfield-1.0.1.tar.gz
Running setup.py (path:/private/tmp/pip_build_root/django-enumfield/setup.py) egg_info for package django-enumfield
Installing collected packages: django-enumfield
Running setup.py install for django-enumfield
Successfully installed django-enumfield
Cleaning up...
$ python
Python 2.7.5 (default, Aug 25 2013, 00:04:04)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from django_enumfield import enum
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named django_enumfield
>>> from django-enumfield import enum
File "<stdin>", line 1
from django-enumfield import enum
^
SyntaxError: invalid syntax
>>>
Thank you to #SaeX.
My $PYTHONPATH was not set correctly.
Oops.