I successfully installed nltk and works fine in python 3.6.3. I have to run a file where nltk was imported and tensorflow too ,hence, i have to activate tensorflow.
HP-250-G5-Notebook-PC:~$ python
Python 3.6.3 |Anaconda custom (64-bit)| (default, Oct 13 2017, 12:02:49)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import nltk
>>>
When I activate tensorflow seems to use python 3.5.2.
(tensorflow)HP-250-G5-Notebook-PC:~/AIG2018/Chatbot$ python
Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import nltk
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
When I look up for solutions this is what I tried but no positive results.
(tensorflow) country_boy#Shikongo-Veijo-HP-250-G5-Notebook-PC:~$ pip install nltk
Traceback (most recent call last):
File "/home/country_boy/tensorflow/bin/pip", line 6, in <module>
from pkg_resources import load_entry_point
File "/home/country_boy/tensorflow/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2927, in <module>
#_call_aside
File "/home/country_boy/tensorflow/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2913, in _call_aside
f(*args, **kwargs)
File "/home/country_boy/tensorflow/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2952, in _initialize_master_working_set
add_activation_listener(lambda dist: dist.activate())
File "/home/country_boy/tensorflow/lib/python3.5/site-packages/pkg_resources/__init__.py", line 956, in subscribe
callback(dist)
File "/home/country_boy/tensorflow/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2952, in <lambda>
add_activation_listener(lambda dist: dist.activate())
File "/home/country_boy/tensorflow/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2515, in activate
declare_namespace(pkg)
File "/home/country_boy/tensorflow/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2097, in declare_namespace
_handle_ns(packageName, path_item)
File "/home/country_boy/tensorflow/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2047, in _handle_ns
_rebuild_mod_path(path, packageName, module)
File "/home/country_boy/tensorflow/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2066, in _rebuild_mod_path
orig_path.sort(key=position_in_sys_path)
AttributeError: '_NamespacePath' object has no attribute 'sort'
I think this has to do with pip. The question is how do i install nltk in python 3.5.2??? Or how to i make everything work??
Related
I saw someone was answering the same question here: Python for Naoqi (dynamic module not initialized properly), but I follow the answers in the page, still cannot get it working. Could someone advice how to proceed?
Using Python 2.7.10 doesn't help.
Under Anaconda Python 2.7.10:
Python 2.7.10 |Continuum Analytics, Inc.| (default, Oct 19 2015, 18:31:17)
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import naoqi
Traceback (most recent call last):
File "/opt/anaconda3/envs/pepper_test2/lib/python2.7/site.py", line 557, in <module>
main()
File "/opt/anaconda3/envs/pepper_test2/lib/python2.7/site.py", line 539, in main
known_paths = addusersitepackages(known_paths)
File "/opt/anaconda3/envs/pepper_test2/lib/python2.7/site.py", line 275, in addusersitepackages
user_site = getusersitepackages()
File "/opt/anaconda3/envs/pepper_test2/lib/python2.7/site.py", line 250, in getusersitepackages
user_base = getuserbase() # this will also set USER_BASE
File "/opt/anaconda3/envs/pepper_test2/lib/python2.7/site.py", line 240, in getuserbase
USER_BASE = get_config_var('userbase')
File "/opt/anaconda3/envs/pepper_test2/lib/python2.7/sysconfig.py", line 520, in get_config_var
return get_config_vars().get(name)
File "/opt/anaconda3/envs/pepper_test2/lib/python2.7/sysconfig.py", line 453, in get_config_vars
import re
File "/opt/anaconda3/envs/pepper_test2/lib/python2.7/re.py", line 108, in <module>
import _locale
SystemError: dynamic module not initialized properly
Under Mac System Python 2.7.10:
Python 2.7.10 (default, Oct 6 2017, 22:29:07)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import naoqi
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/cchan/Documents/technical/python_sdk/pynaoqi-python2.7-2.5.5.5-mac64/lib/python2.7/site-packages/naoqi.py", line 9, in <module>
import qi
File "/Users/cchan/Documents/technical/python_sdk/pynaoqi-python2.7-2.5.5.5-mac64/lib/python2.7/site-packages/qi/__init__.py", line 88, in <module>
from _qi import Application as _Application
ImportError: dlopen(/Users/cchan/Documents/technical/python_sdk/pynaoqi-python2.7-2.5.5.5-mac64/lib/python2.7/site-packages/_qi.so, 2): Library not loaded: /Library/Frameworks/Python.framework/Versions/2.7/Python
Referenced from: /Users/cchan/Documents/technical/python_sdk/pynaoqi-python2.7-2.5.5.5-mac64/lib/python2.7/site-packages/_qi.so
Reason: image not found
I have also added the PYTHONPATH in my ~/.bash_profile:
export PYTHONPATH="$PYTHONPATH:/Users/cchan/Documents/technical/python_sdk/pynaoqi-python2.7-2.5.5.5-mac64/lib/python2.7/site-packages"
export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:/Users/cchan/Documents/technical/python_sdk/pynaoqi-python2.7-2.5.5.5-mac64/lib"
export DYLD_FRAMEWORK_PATH="$DYLD_FRAMEWORK_PATH:/Users/cchan/Documents/technical/python_sdk/pynaoqi-python2.7-2.5.5.5-mac64"
Could someone advise what to do? Thanks in advance!
I found out the problem. The system Python 2.7.10 came with the Mac OS X doesn't work. I have to download the Python 2.7.10 from the Python website and install that in order to have it work: Python Release Website
This answer was original posted by Calvin in question see revision 2
I have installed pyjnius module in python 2.7.12. I don't really remember how did I installed it.
I have a simple script:
#!/usr/bin/python
from jnius import autoclass
# do something here
I can run this without getting any error but when I try to write my code in the python shell, it gives an error.
Python 2.7.12 (default, Nov 19 2016, 06:48:10)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from jnius import autoclass
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/jnius/__init__.py", line 13, in <module>
from .reflect import * # noqa
File "/usr/local/lib/python2.7/dist-packages/jnius/reflect.py", line 14, in <module>
class Class(with_metaclass(MetaJavaClass, JavaClass)):
File "/usr/local/lib/python2.7/dist-packages/six.py", line 827, in __new__
return meta(name, bases, d)
File "jnius/jnius_export_class.pxi", line 43, in jnius.MetaJavaClass.__new__ (jnius/jnius.c:18031)
File "jnius/jnius_export_class.pxi", line 65, in jnius.MetaJavaClass.resolve_class (jnius/jnius.c:18439)
File "jnius/jnius_env.pxi", line 11, in jnius.get_jnienv (jnius/jnius.c:3710)
File "jnius/jnius_jvm_dlopen.pxi", line 90, in jnius.get_platform_jnienv (jnius/jnius.c:3641)
File "jnius/jnius_jvm_dlopen.pxi", line 45, in jnius.create_jnienv (jnius/jnius.c:2965)
File "/usr/lib/python2.7/UserDict.py", line 40, in __getitem__
raise KeyError(key)
KeyError: 'JAVA_HOME'
Is there something wrong with my pyjnius?
I tried to uninstall my current pyjnius module using:
sudo apt-get purge pyjnius
But it says:
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package pyjnius
I would appreciate any hints to my problem.
I'm having trouble using the vendor-supplied boto3 on Ubuntu Trusty. Has anyone else run into this issue, and if so how did you resolve?
FWIW, boto3 works fine in a venv on the same machine, so I think this is a packaging issue. I need to make boto3 available on 1000+ machines, so using the vendor-supplied package is desirable.
I tried installing lxml, cssselect, and requests manually as described in
How to fix ImportError: No module named packages.urllib3? but that didn't solve the problem.
Thanks,
Jeffrey
vagrant#vagrant-ubuntu-trusty-64:~$ cat /etc/issue
Ubuntu 14.04.3 LTS \n \l
vagrant#vagrant-ubuntu-trusty-64:~$ sudo aptitude install python-boto3
....
vagrant#vagrant-ubuntu-trusty-64:~$ python
Python 2.7.6 (default, Oct 26 2016, 20:30:19)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import boto3
>>> boto3.__version__
'1.2.2'
>>> boto3.resource('s3')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/boto3/__init__.py", line 87, in resource
return _get_default_session().resource(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/boto3/session.py", line 292, in resource
aws_session_token=aws_session_token, config=config)
File "/usr/lib/python2.7/dist-packages/boto3/session.py", line 200, in client
aws_session_token=aws_session_token, config=config)
File "/usr/lib/python2.7/dist-packages/botocore/session.py", line 796, in create_client
client_config=config, api_version=api_version)
File "/usr/lib/python2.7/dist-packages/botocore/client.py", line 59, in create_client
cls = self._create_client_class(service_name, service_model)
File "/usr/lib/python2.7/dist-packages/botocore/client.py", line 76, in _create_client_class
base_classes=bases)
File "/usr/lib/python2.7/dist-packages/botocore/hooks.py", line 226, in emit
return self._emit(event_name, kwargs)
File "/usr/lib/python2.7/dist-packages/botocore/hooks.py", line 209, in _emit
response = handler(**kwargs)
File "/usr/lib/python2.7/dist-packages/boto3/utils.py", line 59, in _handler
module = import_module(module)
File "/usr/lib/python2.7/dist-packages/boto3/utils.py", line 52, in import_module
__import__(name)
File "/usr/lib/python2.7/dist-packages/boto3/s3/inject.py", line 13, in <module>
from boto3.s3.transfer import S3Transfer
File "/usr/lib/python2.7/dist-packages/boto3/s3/transfer.py", line 138, in <module>
from requests.packages.urllib3.exceptions import ReadTimeoutError
ImportError: No module named packages.urllib3.exceptions
On the same machine, installing boto3 in a venv seems to work fine. (At least I'm able to create a ServiceResource() object.)
vagrant#vagrant-ubuntu-trusty-64:~$ virtualenv venv-boto3
New python executable in venv-boto3/bin/python
Installing setuptools, pip...done.
vagrant#vagrant-ubuntu-trusty-64:~$ source venv-boto3/bin/activate
(venv-boto3)vagrant#vagrant-ubuntu-trusty-64:~$ pip install boto3
Downloading/unpacking boto3
Downloading boto3-1.4.4-py2.py3-none-any.whl (127kB): 127kB downloaded
...
(venv-boto3)vagrant#vagrant-ubuntu-trusty-64:~$ python
Python 2.7.6 (default, Oct 26 2016, 20:30:19)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import boto3
>>> boto3.__version__
'1.4.4'
>>> boto3.resource('s3')
s3.ServiceResource()
This question already has answers here:
IPython Notebook locale error [duplicate]
(4 answers)
Closed 6 years ago.
I installed the matplotlib and seaborn successfully, however, when I import them in the python shell, many errors occur.
Python 2.7.11 |Anaconda 2.5.0 (x86_64)| (default, Dec 6 2015, 18:57:58)
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/guanqingliang/anaconda/lib/python2.7/site-packages/matplotlib/__init__.py", line 1131, in <module>
rcParams = rc_params()
File "/Users/guanqingliang/anaconda/lib/python2.7/site-packages/matplotlib/__init__.py", line 975, in rc_params
return rc_params_from_file(fname, fail_on_error)
File "/Users/guanqingliang/anaconda/lib/python2.7/site-packages/matplotlib/__init__.py", line 1100, in rc_params_from_file
config_from_file = _rc_params_in_file(fname, fail_on_error)
File "/Users/guanqingliang/anaconda/lib/python2.7/site-packages/matplotlib/__init__.py", line 1018, in _rc_params_in_file
with _open_file_or_url(fname) as fd:
File "/Users/guanqingliang/anaconda/lib/python2.7/contextlib.py", line 17, in __enter__
return self.gen.next()
File "/Users/guanqingliang/anaconda/lib/python2.7/site-packages/matplotlib/__init__.py", line 1000, in _open_file_or_url
encoding = locale.getdefaultlocale()[1]
File "/Users/guanqingliang/anaconda/lib/python2.7/locale.py", line 543, in getdefaultlocale
return _parse_localename(localename)
File "/Users/guanqingliang/anaconda/lib/py`enter code here`thon2.7/locale.py", line 475, in _parse_localename
raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: UTF-8
You need to add the following two lines to your ~/.bash_profile and then type source ~/.bash_profile or restart the terminal:
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
I installed matplotlib with brew install matplotlib --with-cairo --with-pygtk --with-python3. Running import matplotlib.pyplot causes a GTK ImportError. The ImportError is slightly different for Python 2 and 3.
Python 2:
$ python
Python 2.7.8 (default, Oct 16 2014, 05:18:45)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.51)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib.pyplot
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/matplotlib-override/matplotlib/pyplot.py", line 98, in <module>
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "/Library/Python/2.7/site-packages/matplotlib-override/matplotlib/backends/__init__.py", line 28, in pylab_setup
globals(),locals(),[backend_name],0)
File "/Library/Python/2.7/site-packages/matplotlib-override/matplotlib/backends/backend_gtkcairo.py", line 12, in <module>
from matplotlib.backends.backend_gtk import *
File "/Library/Python/2.7/site-packages/matplotlib-override/matplotlib/backends/backend_gtk.py", line 33, in <module>
from matplotlib.backends.backend_gdk import RendererGDK, FigureCanvasGDK
File "/Library/Python/2.7/site-packages/matplotlib-override/matplotlib/backends/backend_gdk.py", line 30, in <module>
from matplotlib.backends._backend_gdk import pixbuf_get_pixels_array
ImportError: No module named _backend_gdk
Python 3:
$ python3
Python 3.4.2 (default, Oct 16 2014, 05:21:12)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.51)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib.pyplot
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.4/site-packages/matplotlib/pyplot.py", line 109, in <module>
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "/usr/local/lib/python3.4/site-packages/matplotlib/backends/__init__.py", line 32, in pylab_setup
globals(),locals(),[backend_name],0)
File "/usr/local/lib/python3.4/site-packages/matplotlib/backends/backend_gtkcairo.py", line 10, in <module>
import gtk
ImportError: No module named 'gtk'