I want to use matplotlib. I have installed it as:
sudo apt-get install python-matplotlib
and in terminal I have:
$ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>> matplotlib.__version__
'1.3.1'
>>> matplotlib.__file__
'/usr/lib/pymodules/python2.7/matplotlib/__init__.pyc'
>>> mpl.get_configdir()
'/home/azh2/.config/matplotlib'
>>>> mpl.get_cachedir()
'/home/azh2/.cache/matplotlib'
now I want to use it. so in pycharm terminal I have:
$ from PIL import Image
from: can't read /var/mail/PIL
What is the problem please? can you help me solve it?
Thank you very much for your help.
You are in shell not in python executing environment.
Related
My system has python3 as the default for python command.
when I try to import flask on python command line I get this:
Python 2.7.15rc1 (default, Apr 15 2018, 21:51:34)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import flask
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named flask
>>>
but in python3 i get this:
Python 3.6.5 |Anaconda, Inc.| (default, Apr 29 2018, 16:14:56)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import flask
>>>
How do i correct this?
It looks you are using two different packaging systems: pip and conda. For Python2, try pip2 install flask.
Any thoughts on what to try when installation of pymc3, using pip, works flawlessly, but as soon as the statement import pymc3 is executed, Python3.6 coredumps ?
$ python3.6
Python 3.6.1 (default, Mar 21 2017, 21:49:16)
[GCC 5.4.0] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
import pymc3
Segmentation fault (minnesutskrift skapad)
TIA,
Tommy
I have installed cassandra 3.0.0 and trying to connect to connect cqlsh. when i try to hit ./bin/cqlsh from the dir of installed cassandra I am getting
python not found. I am using ubunut14.04LTS
when i type python2 in my terminal it says
python2
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
when i type python3 in my terminal it says
python3
Python 3.4.3 (default, Oct 14 2015, 20:28:29)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
so this mean it is already installed . But yes when i type
python in terminal it says
python
The program 'python' is currently not installed. You can install it by typing:
apt-get install python-minimal
even when i install python-minimal it doesn work.
please suggest..
Create a symbolic link /usr/bin/python pointing to either /usr/bin/python2 or /usr/bin/python3
I was having trouble about python unicode and so I reinstalled python on /usr/local/bin/python with option "--enable-unicode=ucs4". I added to ~/.bashrc all the paths to python modules and when I run as common user I'm able to import modules, but when I'm as sudo I can't.
iury#buzios:~$ /usr/local/bin/python
Python 2.7.6 (default, Aug 20 2015, 11:57:25)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>>
iury#buzios:~$ sudo /usr/local/bin/python
Python 2.7.6 (default, Aug 20 2015, 11:57:25)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named numpy
>>>
As their name indicates, Environmental Variables are assigned to your own user. That means that if you are running program as root (using sudo), they won't be "assigned" to the program because it is running in the environment of the root user. A work around is to set the environment variables after the sudo command like this: sudo env PATH=$PATH VAR1=SOME_VALUE VAR2=SOME_VALUE
As the answer in this question indicates, you can add this export in your ./bashrc as a workaround:
alias sudo='sudo env PYTHONPATH=[PATH] PYTHON=[OTHERPATH] ... ./thescript.py
Also, as mentioned in the comments, make sure you need to run python as sudo, as it is not recommended when not REALLY needed.
how can i fix this, or find the logs to investigate it?
$ python
Python 2.7.3 (default, Dec 18 2014, 19:10:20)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from sympy import symbols
>>> from sympy.plotting import plot
OpenGL Warning: Failed to connect to host. Make sure 3D acceleration is enabled for this VM.
>>> x = symbols('x')
>>> p1 = plot(x*x)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'module' object is not callable
>>> import sympy
>>> sympy.__version__
'0.7.1.rc1'
it looks like the plotting module has not been fully installed?
this seems to be a very old version of sympy. the api has changed. in sympy 0.7.1.rc1, plot is a module, not a function.
i solved the issue by removing the existing versions of mpmath and sympy (which had been installed with apt) and installing the latest versions like so:
$ sudo apt-get remove --purge python-mpmath python-sympy
$ sudo python -m easy_install mpmath
$ python
Python 2.7.3 (default, Mar 14 2014, 11:57:14)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import mpmath
>>> mpmath.__version__
'0.19'
$ sudo python -m easy_install sympy
$ python
Python 2.7.3 (default, Mar 14 2014, 11:57:14)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sympy
>>> sympy.__version__
'0.7.6'
now plot() shows the graph.
in future, use python -m easy_install to install the latest version, and not apt-get which has old versions it seems.