I have installed on Mac OS X 10.10:
I have installed Python 2.7.6 default apple
2.7.9 python mac ports
and
Pypy.
When i type pip freeze there a lot of modules installed.
However i can import some modules on one python and not the other one, because not everybody finds all modules.
Can someone explain me how can i achieve that every python version find every installed module?
(and does pip show all installed modules?)
As far as i can tell all modules are at : /Library/Python/2.7/sites-packages. But i don't know why not every python looks there.
How about using virtualenv to manage multiple python? https://virtualenv.pypa.io/en/latest/
If you are not sure about which module you are importing, you could try to print the file of the module ( if the module has this attribute). eg:
macbook:~ mac$ python
Python 2.7.5 (default, Mar 9 2014, 22:15:05)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyQt4 as f
>>> print f.__file__
/Library/Python/2.7/site-packages/PyQt4/__init__.pyc
python will search the PYTHONPATH setting and try to load the module, if there are multiple python module with same name, it actually loads the 1st one.
Related
I have installed Anaconda but still unable to use packages such as pandas and requests when running code on python.
When I input python on Terminal, it shows:
Python 3.6.1 |Anaconda 4.4.0 (x86_64)| (default, May 11 2017, 13:04:09)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
And I also created a virtual environment and activate before opening the python shell:
conda create -n my-env python=3.6 anaconda
However, when reopening and running codes on Python, it kept saying "No module named 'pandas' or "No module named 'requests'" Does anyone know what the problem with this code is? Besides, I am not if version of Python has anything to do with this error? Is it because I am using 3.6.2 Python instead of 3.6.1?
Probably Anaconda became the default Python installation on your system. Specially when you are using a new environment, you have to install the modules you want in this new environment.
Try conda install pandas and, after that, import pandas
linux python and pillow:
I just upgraded to mint 17.3. The docs say this is an Ubuntu14.04 Kernel.
I wish to run python and the python imaging libarary => pillow.
When I run > python < (command line) i get as follows;
grumpy#grumpy-desktop ~ $ 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.
I am assuming that python2.7.6 is the default module used. Within usr/
lib/ python2.6, python2.7, python3 and python3.4 all exist.
However; I have been unable to get the version of PIL or Pillow being used.
PIL exist in usr/lib/python3/dist-packages/PIL, along with
~/Pillow2.3.0.eggs-info (not much help here.)
The docs indicate that Linux mint17.3, with an Umbuntu14.04 Kurnel and
python2.7, that Pillow2.3.0 would be most compatable.
So the question is; How to install Pillow2.3.0, with ALL THE MODULES,
for full functionality. I wish to include in scripts;
Image.putpixel(xy, value)
Image.putdata(data, scale=1.0, offset=0.0)
At present when I run the above I get;
AttributeError: 'module' object has no attribute 'putdata' (or 'putpixel')
or, if needed;
How to change python version used, so to install another Pillow version
with full functionality.
Thanks for the input guys.
I am using paraview 4.3.1 in Centos 7. There is a built-in python named pvpython:
Python 2.7.2 (default, Jan 15 2015, 09:36:49)
[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys;sys.path
['', '/tmp/ParaView-4.3.1-Linux-64bit/lib/paraview-4.3/site-packages/vtk', '/tmp/ParaView-4.3.1-Linux-64bit/lib/paraview-4.3/site-packages', '/tmp/ParaView-4.3.1-Linux-64bit/lib/paraview-4.3', '/tmp/ParaView-4.3.1-Linux-64bit/lib/paraview-4.3/lib/python27.zip', '/tmp/ParaView-4.3.1-Linux-64bit/lib/paraview-4.3/lib/python2.7', '/tmp/ParaView-4.3.1-Linux-64bit/lib/paraview-4.3/lib/python2.7/plat-linux2', '/tmp/ParaView-4.3.1-Linux-64bit/lib/paraview-4.3/lib/python2.7/lib-tk', '/tmp/ParaView-4.3.1-Linux-64bit/lib/paraview-4.3/lib/python2.7/lib-old', '/tmp/ParaView-4.3.1-Linux-64bit/lib/paraview-4.3/lib/python2.7/lib-dynload', '/tmp/ParaView-4.3.1-Linux-64bit/lib/paraview-4.3/lib/python2.7/site-packages']
>>>
The problem is, original pvpython do not support many useful features such as code completion. And there is no setup_tools in the pvpython, so I cannot install new modules to the built-in python.
Could anyone help me to install ipython on this built-in python?
See the install instructions for get-pip:
https://pip.pypa.io/en/latest/installing.html
However, you must use the pvpython instead of python when using the install instructions.
Depending on how you install it, you may end up with more than one easy_install or pip on your path. Just make sure you're using the one associated with pvpython - look at the script you're running to find out (it's just a shell script).
Once you've done that, installing ipython should be the same as installing it with any other version of python (assuming that pvpython doesn't break anything that ipython needs).
I installed igraph for python 2.6 on OSX 10.7, but I cannot import igraph library.
It shows a import error:no module name igraph.
I have no idea. Please help me out.
Thanks.
However, I cannot run code with python. I make a code, and tried to run, such as, 'python ex.py'
OK, even though you didn't answer most of my questions, I'm pretty sure I can guess your problem. Your question title is "I cannot import igraph on python 2.6 after installation", but you're not trying to import it on python 2.6, you're trying on 2.7.
$ python
Python 2.7.2 (default, Jun 20 2012, 16:23:33)
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import igraph
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named igraph
>>>
$ python2.6
Python 2.6.7 (r267:88850, Jun 20 2012, 16:23:38)
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import igraph
>>>
See the difference? OS X 10.7 (and 10.8) comes with three versions of Python: 2.5, 2.6, and 2.7. They're entirely independent installations, so when you installed igraph for Python 2.6, that didn't install it for your 2.5 or 2.7 installations.
The default, the one you get when you just run python, is 2.7. If you want a specific version, you have to run python2.6 instead.
So, you either need to run python2.6, or install igraph for 2.7.
As a side note, if you've installed any third-party Python installations, you're going to get yourself even more confused, so please, don't do that (or uninstall if you already have) until you really know what you're doing.
I am trying to set up working environment on
OS X 10.6.6, XCode3.2, fink using python and cocoa frameworks. I scanned few references in the net, however nothing worked for me.
I have python2.6 installed via fink together with a pyobjc-py26. When I run a python shell in the terminal I get:
localhost:PyObjCTut stymek$ which python
/usr/bin/python
localhost:PyObjCTut stymek$ python
Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import objc
>>>
Everything is OK.
When I try to build the basic code from the Xcode (e.g. 1. default Python + Cocoa template 2. example from here), the python is not able to find objc module. Why?
Traceback (most recent call last):
File "main.py", line 10, in <module>
import objc
ImportError: No module named objc
I was struggling with almost similar troubles after manually installing Python version 2.7 and 3.X...
There's no such setting in XCode - the Apple-shipped Python (v2.6) needs to be the default one.
Also, check in the /System/Library/Frameworks/Python.framework/Versions - the 'Current' symlink needs to point to the default Python v2.6