2

OS: CentOS 6.6 Python 2.7 So, I've (re)installed Canopy after it suddenly stopped working after an abrupt shutdown. It worked fine immediately after the install (I installed as my default Python). But after one reboot, when I try to open it with /root/Canopy/canopy (the icon under applications no longer works, either), I get the following error:

(Canopy 64bit) [xxuser@xxlinux ~]$ /root/Canopy/canopy Traceback (most recent call last):   File "/home/xxuser/qiime_software/sphinx-1.0.4-release/lib/python2.7/site-packages/site.py", line 73, in <module>
    __boot()   File "/home/xxuser/qiime_software/sphinx-1.0.4-release/lib/python2.7/site-packages/site.py", line 2, in __boot
    import sys, imp, os, os.path    ImportError: No module named path

I found this link: Python - os.path doesn't exist: AttributeError: 'module' object has no attribute 'path', but both of my os.py and os.pyc were 250 and 700 bytes, respectively. There was another file called site.py which was 0 bytes and site.pyc was about 100 bytes. What are these files? And would deleting them hurt anything (which is what they did)? And why is this happening after reboot? (using reboot command).

I also found this: https://groups.google.com/forum/#!topic/spyderlib/hKB15JYyLqM , which could be relevant. I've updated my python path before with sys.path.append('/..')

My guess is that for some reason os.path isn't in sys.path? and __boot can't find it? But I'm new to Python and Linux and want to know what I'm doing before I go modifying any boot files, paths, etc.

Thanks in advance.

More information (saw that I'm supposed to update new info in an edit to original question. New to this.)

From one of the comments:
This is what I got:

import os.path

import posixpath

os.path

module 'posixpath' from '/home/xxuser/qiime_software/python-2.7.3-release/lib/python2.7/posixpath.pyc'

posixpath

module 'posixpath' from '/home/xxuser/qiime_software/python-2.7.3-release/lib/python2.7/posixpath.pyc'

Looks like os.path is there. Could this have to do with a permissions error? I have it installed to /root/Canopy/canopy and I found this: docs.python.org/2/library/os.html#module-os (section 15.1.4). Does that make sense? I'm also not sure if the following is related, but it might possibly. I can no longer seem to update my path with sys.path.append('/file/path/here'). It works until I close the terminal, then I have to re-append the next time I want to call a module from the new directory. Are sys.path and os.path related in any way?

Tichigan
  • 65
  • 1
  • 9
  • What are the values of env vars `PYTHONPATH` and `PYTHONHOME` (if any, preferably not!) – Jonathan March Jan 22 '15 at 22:56
  • It might help and it won't hurt to delete directories `~/.canopy` and `~/Enthought/Canopy_64bit/System`, and try again – Jonathan March Jan 22 '15 at 22:59
  • @JonathanMarch. If I >>>print PYTHONPATH it says 'PYTHONPATH' is not defined. Same for PYTHONHOME. Is this how I should query it? I will try deleting those directories. By try again, do you mean try the entire install again? – Tichigan Jan 23 '15 at 00:54

3 Answers3

4

Just fixed this on OSX with:

brew uninstall python
brew install python

No idea why, never seen it in 5 years of working with Python :S

pzrq
  • 1,626
  • 1
  • 18
  • 24
1

It turns out that I was onto something with my last comment. I'd downloaded a bunch of biology modules that depend on python, and so many of them came with their own install. When I added the modules to ~/.bashrc, my bash began calling them in advance of my original CentOS install. Resetting ~/.bashrc and restarting (for some reason source ~/.bashrc didn't work) eliminated all of the extra stuff I'd added to my $PATH and Canopy began working again. I'm going to go through and remove the extra installations of python and hopefully the issue will be behind me. Thanks to everyone who posted answers, especially A.J., because that's what got me thinking about .bashrc .

Edit: With some better understanding, this was all because of using python in a virtual environment. Canopy was resetting my path every time I opened it. I'm using a self-installed virtual environment now and have configured my path.

Tichigan
  • 65
  • 1
  • 9
0

Try seeing if you have posixpath by typing import posixpath:

>>> import os.path
>>> os.path
<module 'posixpath' from '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/posixpath.pyc'>
>>> ^D
bash-3.2$ python
>>> import posixpath
>>> posixpath
<module 'posixpath' from '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/posixpath.pyc'>
>>> 
A.J. Uppal
  • 19,117
  • 6
  • 45
  • 76
  • Got cut off: This is what I got: >>> import os.path >>> import posixpath >>> os.path >>> posixpath . Looks like os.path is there. Could this have to do with a permissions error? I have it installed to /root/Canopy/canopy and I found this: https://docs.python.org/2/library/os.html#module-os (section 15.1.4). Does that make sense? – Tichigan Jan 22 '15 at 19:08
  • Hmmmm... that's odd. So it wasn't working, and now it was? Interesting, i'll have to look into it. But in the mean time, glad that it worked! Also, if this answer helped you, would you mind accepting it? (Click on the green check next to my answer [It gives **you** reputation too!]) – A.J. Uppal Jan 23 '15 at 02:33
  • No, it is still not working. I can only get into Python with command line and I can't add anything to my sys.path. Looking at this, I see that it's using a python that looks like it was automatically installed with QIIME, rather than the 'factory' centos install. I'm wondering if that's the problem and trying to reset my .bashrc to default using cp /etc/skel/.bashrc ~/ and then resetting with source ~/.bashr but all of the QIIME directories still show when I echo $PATH. – Tichigan Jan 23 '15 at 18:18