I am using CSD software on Linux. After installation, I could use CSD python API through the icon shortcut appeared on the desktop. But if I want to launch the script by CSD Python API by addressing it (not through the icon) I face difficulties. To launch the script by Python API, first I go to the directory of the script and then address the directory in which the Python API folder is located:

terminal:

cd /Desktop (Script Location)

In this directory I type:

 /...../Python API/miniconda/bin/python2 (press enter)

script.py

I see this error message:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'script' is not defined

If I copy the script lines to the Python API opened by its Icon, it works without any problem. Could you please help me out?

P.S. I have both versions of Python 2.7 and 3.6.5  (the later through anaconda). I call python 2 with source activate command.

Hi Tahereh,

you can run the script directly by:

/.../Python API/miniconda/bin/python2 script.py

or you can activate the python:

/.../Python API/miniconda/bin/activate

then run:

python script.py

I hope this is helpful.  If not, please get back to me.

Best wishes

Richard

 

 Thanks Richard. I followed the suggestions but again I got errors:

The first command leads to:

/..../Python_API_2018/miniconda/lib/python2.7/site-packages/ccdc/__init__.py:268: UserWarning:
Could not find the CSD-System installation.

For further help with installing and configuring data please visit
the support page at https://www.ccdc.cam.ac.uk/csds_install_help

Usage of the CSD Python API without the CSD Data installed is not supported.

  warnings.warn(CSDHOME_NOT_FOUND_MSG)
Traceback (most recent call last):
  File "hydrates_filter.py", line 4, in <module>
    settings = search.Search.Settings()
  File "/..../Python_API_2018/miniconda/lib/python2.7/site-packages/ccdc/search.py", line 830, in __init__
    _settings = CSDSQLDatabaseLib.GenericCrystalStructureDatabaseSearchSettings()
  File "/......./Python_API_2018/miniconda/lib/python2.7/site-packages/ccdc/_lib/CSDSQLDatabaseLib.py", line 1117, in __init__
    this = _CSDSQLDatabaseLib.new_GenericCrystalStructureDatabaseSearchSettings(*args)
RuntimeError: Welcome to the CSD Python API.
No valid licence located. Access is available to all organisations and institutions.
To find details for your company or university please contact admin@ccdc.cam.ac.uk.

 

I don't understand this error as I have downloaded the Software through the valid Site No. and Confirmation Code  provided by my University. The installation has been made by this command: ./csds-linux-x64.run

 

2- The second command gives rise to:

Error: activate must be sourced. Run 'source activate envname'
instead of 'activate envname'.

Usage: source activate ENV

Adds the 'bin' directory of the environment ENV to the front of PATH.
ENV may either refer to just the name of the environment, or the full
prefix path.

 

and if I change activate to source activate it says no such a file or directory.

 

Do you think there is problem in installation?

Many thanks,

Tahereh

Hi Tahereh,

on a linux system you will need to set the environment variable CSDHOME to point to where you installed the CSD:

export CSDHOME=/..../CSD_2018

which will enable the API to find the CSD and other files in your installation.

Sorry about the mistake in the second form.  It should read

source /.../CSD_2018/Python_API_2018/miniconda/bin/activate

which will set the default python, here called 'base'.  This should appear at the start of your prompt string as (base) followed by the rest of the prompt string.

Best wishes

Richard

 Many thanks. It seems the problem is fixed now.

Good to hear.  Let me know if any other problems crop up.

Best wishes

Richard

Hi,

I am trying to use openbabel through CSD python API (from openbabel import *) but the code fails:

ImportError: No module named openbabel

 

 I've installed openbabel through anaconda and can use that in python2 without any difficulty.

I'd be appreciated if you can help me to sort out this error.

 

Thanks a lot,

Tahereh

You must be signed in to post in this forum.