d0ugal / RstPreview

RstPreview - a SublimeText plugin to view RST files in your browser.
Other
22 stars 13 forks source link

Problems installing docutils. #13

Open Egg932 opened 12 years ago

Egg932 commented 12 years ago

This plugin does not work at all! I lost a lot of time to try to run it properly.

Don't work on Windows or on Linux.

I retract my opinion if the author proves to correct rst preview by this plugin, for example a publish some video or screencast on YouTube.

d0ugal commented 12 years ago

Hi! Thanks for the report.

Did you follow the brief and probably not complete enough steps in the Readme? Can you let me what you tried and what errors you received if any?

I can't help too much with Windows as I don't use it, but I can confirm that it works in OSX and Ubuntu.

Here is it working on my mac...

Egg923 commented 12 years ago

Hi! It's me, but other account, because I forgot password.

You said:

what errors you received if any?

Any? One the same error over and over: http://i.imgur.com/7fskh.png Note, that I've installed the docutils module before I run the Sublime Text 2. See below

[root@localhost ~]# easy_install-2.6 docutils
Searching for docutils
Reading http://pypi.python.org/simple/docutils/
Reading http://docutils.sourceforge.net/
Reading http://sourceforge.net/projects/docutils/files/docutils/0.9.1/docutils-0.9.1.tar.gz/download
Reading http://sourceforge.net/projects/docutils/files/docutils/0.8.1/docutils-0.8.1.tar.gz/download
Reading http://sourceforge.net/projects/docutils/files/docutils/0.9/docutils-0.9.tar.gz/download
Best match: docutils 0.9.1
Downloading http://pypi.python.org/packages/source/d/docutils/docutils-0.9.1.tar.gz#md5=b0d5cd5298fedf9c62f5fd364a274d56
Processing docutils-0.9.1.tar.gz
Writing /tmp/easy_install-JQNqss/docutils-0.9.1/setup.cfg
Running docutils-0.9.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-JQNqss/docutils-0.9.1/egg-dist-tmp-0eDOZg
...
Installed /usr/lib/python2.6/site-packages/docutils-0.9.1-py2.6.egg
Processing dependencies for docutils
Finished processing dependencies for docutils

Test the docutils import and version:

[centos@localhost ~]$ python
Python 2.6.6 (r266:84292, Jun 18 2012, 14:10:23) 
[GCC 4.4.6 20110731 (Red Hat 4.4.6-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import docutils
>>>
>>> docutils.__version__
'0.9.1'

As you see, the docutils module is definitely (100%) installed properly on the Linux system in the Python global libraries. So what am I doing wrong?

d0ugal commented 12 years ago

Well, it seems that docutils actually isn't definitely (100%) installed properly in the correct Python version. Do you have multiple Python versions installed?

In sublime, can you press ctrl + ` and you should see a python prompt. The keyboard shortcut may be different, I only know the mac one. Once you see it try typing these commands and see if you get the same result as me (you shouldn't see an error).

sublime python console screen shot

Egg923 commented 12 years ago

Hello again! Thank you for your answer, assistance and patience. :-)

Do you have multiple Python versions installed?

No. I've only one Python, 2.6.6 version

In sublime console I get following error:

>>> import docutils
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named docutils

Could you please give me output from following command from your Sublime Console (Ctrl+`) on your Mac?

from pprint import pprint as pp
pp(sys.path)
d0ugal commented 12 years ago
>>> import pprint
>>> pprint.pprint(sys.path)
['/Users/dougal/Library/Application Support/Sublime Text 2/Packages/SublimeLinter/sublimelinter/modules/libs',
 '/Users/dougal/Library/Application Support/Sublime Text 2/Packages/SublimeCodeIntel/libs',
 '/Library/Python/2.6/site-packages/pip-1.1-py2.6.egg',
 '/Library/Python/2.6/site-packages/docutils-0.9-py2.6.egg',
 '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python26.zip',
 '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6',
 '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-darwin',
 '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac',
 '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac/lib-scriptpackages',
 '/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python',
 '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk',
 '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-old',
 '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload',
 '/Library/Python/2.6/site-packages',
 '/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/PyObjC',
 '.']
d0ugal commented 12 years ago

If you have any suggestions or are able to bundle docutils with RstPreview I'd love to do that. I tried but couldn't get it to work. It was in a previous release but I removed it due to problems.

Egg923 commented 12 years ago

Thx! I noticed one, big difference, that you have a lot more Python paths than I've in Linux.

My output from console (Ctrl+`) after starting Sublime Text 2:

startup, version: 2217 linux x32 channel: stable
executable: /opt/sublimetext2/sublime_text
working dir: /home/centos
packages path: /home/centos/.config/sublime-text-2/Packages
settings path: /home/centos/.config/sublime-text-2/Settings
libgio version is less than 2.26, single instance support disabled
PackageSetup not required
Py_GetProgramName(): sublime_text
Py_GetExecPrefix(): .
Py_GetProgramFullPath(): 
Py_GetPath(): ./lib/python26.zip:./lib/python2.6/:./lib/python2.6/plat-linux2:./lib/python2.6/lib-tk:./lib/python2.6/lib-old:./lib/python2.6/lib-dynload
Py_GetPythonHome(): .
catalogue loaded
found 5 files for base name Default.sublime-keymap
found 1 files for base name Default.sublime-mousemap
found 2 files for base name Main.sublime-menu 
...
...
app ready

And my sys.path inside ST2:

>>> from pprint import pprint as pp
>>> pp(sys.path)
['/opt/sublimetext2/lib/python26.zip',
 '/opt/sublimetext2/lib/python2.6',
 '/opt/sublimetext2/lib/python2.6/plat-linux2',
 '/opt/sublimetext2/lib/python2.6/lib-tk',
 '/opt/sublimetext2/lib/python2.6/lib-old',
 '/opt/sublimetext2/lib/python2.6/lib-dynload',
 '.']

I don't have Mac computer (you lucky man! ;-)) so I don't know why your paths so plentiful.

Egg923 commented 12 years ago

If you have some time try run your plugin in Linux in following two, simple steps:

Cipscis commented 12 years ago

I'm also having issues installing this plugin, although I'm on Windows 7. I see the same errors as Egg923 when I attempt to run the RST Preview command and when I attempt to import docutils in Sublime's Python console, but I have Python 2.7 installed and I can import docutils just fine via python.exe instead of Sublime.

Here is my sys.path from inside Sublime:

>>> from pprint import pprint as pp
>>> pp(sys.path)
['python26.zip',
 '.',
 u'C:\\Users\\mark.hanna\\AppData\\Roaming\\Sublime Text 2\\Packages\\AAAPackageDev/Lib']

I don't think I've done anything strange, but I have basically no experience with Python. All I've done is follow the installation instructions word for word.

d0ugal commented 12 years ago

@Egg932 Sorry for the lack of reply, was on holiday. I don't really have time to setup a centos machine and test at the moment.

@Cipscis Hmm, that's probably my fault. I don't use windows and don't have a way to test. So some of the instructions are a guess or based on what people have told me. We could do with somebody that is experienced with Python on windows to help out with this.

Cipscis commented 12 years ago

Okay, thanks for the reply. In the meantime I'm just previewing it manually with this online reST renderer. It'd be great to get this plugin working though, so I'll keep an eye on it and if I manage to get it working on my Windows setup I'll let you know what I had to do.

d0ugal commented 11 years ago

As of db036f145fa8a2ebea8e80836ebc033092783269 you can now use a virtualenv for docutils thanks to @takuan-osho. I have still to update the README but this may well help you with this.

claws commented 11 years ago

I am getting this problem too. My mac is running OSX 10.8.2 which uses Python2.7 and I installed docutils using 'sudo pip install docutils' which installs docutils into the system Python2.7. A restart of ST2 fails with the same error noted above - ST2 can't import docutils. I'm new to ST2 but a little investigation seems to indicate that I should in fact be installing docutils into the ST2 embedded Python (which I think is Python2.6). Does this sound right?

d0ugal commented 11 years ago

I think ST2 uses the system Python2.6. So, sudo easy_install-2.6 docutils may work.

jack-pappas commented 11 years ago

Hi @d0ugal and @Cipscis -- I just installed this plugin on my Windows 7 desktop, where I have Python 2.7 installed. After installing docutils (according to the instructions that come with it), I just had to make one simple tweak to get things working.

Open the settings file RstPreview.sublime-settings in ST2; if your username is JohnDoe, the file should be located at:

C:\Users\JohnDoe\AppData\Roaming\Sublime Text 2\Packages\RstPreview\RstPreview.sublime-settings

In the settings file, change the value of site_packages_path from null to the site-packages folder for your Python installation. On my machine, I used the default settings when installing Python, so the path was:

C:\Python27\Lib\site-packages

Whatever path you use, you need to make one last change -- the plugin seems to only accept paths which use UNIX-style path separators, so you need to change \ to / in the path. The final result on my machine is:

"site_packages_path": "C:/Python27/Lib/site-packages"

Save the changes to the settings file and close it. Now you should be able to open a ReStructured Text file and press Ctrl+Shift+r to preview it.

Joshua-Snapp commented 11 years ago

Thanks @d0ugal and @markotibold for the RSTPreview package! Thanks @jack-pappas for pointing me to the settings file RstPreview.sublime-settings.

I just installed RstPreview yesterday and ran into similar problems as @claws and @Egg923.

Here's the solution that worked for me.

My situation: I just recently did a fresh install of Ubuntu so I had to install python-setuptools to get the easy-install tool to be able to install docutils.

sudo apt-get install python-setuptools sudo easy-install docutils

Now my environment is as listed below... Platform = Ubuntu 12.10 64 bit Python version = 2.7 docutils version = 0.10

Sublime Text 2 wasn't picking up on the fact that I had installed docutils, so I got the "Install docutils" message every time I tried to run RSTPreview.

Immediately after running RSTPreview (and getting the popup message), I could see the following message if I brought up the python console in ST by pressing `CTRL+``

Traceback (most recent call last): File "./sublime_plugin.py", line 362, in run_ File "./RstPreview.py", line 78, in run File "./RstPreview.py", line 22, in rst_to_html ImportError: No module named docutils.core

I found where docutils was located by using find.

sudo find / -type d -iname "docutils"

Then I pasted the location into the RstPreview.sublime-settings file.

{ // Where to look for python site-packages directory. // Use absolute path, not relative path. // For example, "/Users/foo/.virtualenvs/env/lib/python2.x/site-packages". "site_packages_path": "/usr/local/lib/python2.7/dist-packages/docutils-0.10-py2.7.egg" }

Now, I just had to close and reopen Sublime Text 2 and try RSTPreview again. It works! Yay!

ref. Docutils Release Procedure

in /usr/local/lib/python2.7 are dist-packages site-packages. site-packages is empty. docutils is installed under dist-packages.

I don't know why docutils installs to dist-packages instead of site-packages. I'd be interested in knowing if there is a better way of handling this, but this worked for me.

Thanks again for a useful package!

d0ugal commented 11 years ago

Thanks @Joshua-Snapp for the awesome level of detail.

I'm going to try and pull this out and add some more detail to the README.

I also just remembered that python-docutils is available as a deb package too. sudo apt-get install docutils may be an easier solution for some people.

I think part of the problem we have is that sometimes Sublime uses a bundled version of Python or sometimes it uses the system Python. If you have two versions running locally then I think it can get confused about which to use and may not use the default. In SublimeText 3 it looks like it will always bundle its own version of Python - this will be great because its more consistent but I've no idea how that will work for installing something like docutils.

Joshua-Snapp commented 11 years ago

I'm not the most well versed person on these tools, so your help is appreciated.

You mention that Sublime might get confused if a person has more than one version of Python running. I figured that's why the RstPreview.sublime-settings exists. Correct me if my understanding is wrong here. As long as someone manually identifies the path to docutils in the RstPreview.sublime-settings file, then your RSTPreview package should work, right? If I understand that correctly, then that's a small inconvenience that I think we as users should be willing to live with, especially if it is pointed out in the README.rst. I mean, it was quite satisfying to resolve at least my problem with your package and get to watch it in all its glory as it blasted a new browser tab open with a preview of my work. Of course, that's my opinion! :)

olkkoo commented 11 years ago

I am facing this same problem. I get the same error about not being able to load docutils.

My ST2 is using its own Python 2.6.6. In sys.path there are only ST2-related directories, not any system-Python directories. Adding the path to system-Python's site-packages in RstPreview.sublime-settings doesn't append it to sys.path even when restarting ST2. I cannot import docutils in ST2 console, either.

It would be great to get this working.

I am running Archlinux and I have docutils-0.10 installed for both Python2.7 and Python3, for that matters.

d0ugal commented 11 years ago

I don't have a solution for this I'm afriad. It seems Sublime is moving to a more sandboxed Python install too. See SublimeText 3 where it always bundles its own Python. So, I think we need to take a step back and try to find a way to bundle docutils or a similar package.