Hi
I'm no Python expert, but I think the problem is that Python doesn't (by
default) do filename globbing. As a result it doesn't understand the
significance of the ~ character in your directory path and tries to
interpret it literally. The simple solution is to just give a path that can
be interpreted directly (e.g.
/home/your_username/Desktop/rest_of_the_path), alternatively install the
Python glob module to parse your current path. The former seems to be a
much simpler solution!
Best regards,
Chris
On 11 July 2018 at 00:28, Phuong Chau wrote:
> Thank you so much!
>
> On Tue, Jul 10, 2018 at 4:33 PM, Malitha Kabir
> wrote:
>
>> Hi,
>>
>> Probably the designated folder is missing. So, rdkit cannot create the
>> file in specified path. Thanks.
>>
>> - malitha
>>
>> On Wed, Jul 11, 2018, 5:46 AM Phuong Chau wrote:
>>
>>> Hello,
>>>
>>> I was trying to draw the 2D structure of a molecule inside a python
>>> script (.py). It works with other functions such as MolToSmiles,
>>> FingerPrintMol(),... but somehow the Draw.MolToSmile() function does not
>>> work. It kept throw errors of:
>>> File "PairsFinder.py", line 53, in
>>> Draw.MolToFile(chem,'~/Desktop/work/2018/July/10/500_v2/
>>> Chem1_avg7.png')
>>> File "/usr/lib/python2.7/dist-packages/rdkit/Chem/Draw/__init__.py",
>>> line 182, in MolToFile
>>> canvas.save()
>>> File "/usr/lib/python2.7/dist-packages/rdkit/Chem/Draw/spingCanvas.py",
>>> line 111, in save
>>> self.canvas.save()
>>> File "/usr/lib/python2.7/dist-packages/rdkit/sping/PIL/pidPIL.py",
>>> line 166, in save
>>> self._image.save(filename, format=format)
>>> File "/usr/lib/python2.7/dist-packages/PIL/Image.py", line 1672, in
>>> save
>>> fp = builtins.open(filename, "wb")
>>> IOError: [Errno 2] No such file or directory:
>>> '~/Desktop/work/2018/July/10/500_v2/Chem1_avg7.png'
>>> My script is :
>>> chem = Chem.MolFromSmiles('Nc1c1F')
>>> Draw.MolToFile(chem,'~/Desktop/work/2018/July/10/500_v2/Chem1_avg7.png')
>>>
>>> Would anyone help me please? How do I run Draw in python script?
>>>
>>> Thank you so much for your help
>>> --
>>> Phuong Chau
>>> Smith College '20
>>> Engineering Major
>>>
>>> --
>>> Check out the vibrant tech community on one of the world's most
>>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot__
>>> _
>>> Rdkit-discuss mailing list
>>> Rdkit-discuss@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>>>
>>
>
>
> --
> Phuong Chau
> Smith College '20
> Engineering Major
>
>
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> ___
> Rdkit-discuss mailing list
> Rdkit-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>
>
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss