Search code examples
pythonwindows-installeranacondaconda

Error while constructing custom Anaconda installer on Windows


I am creating a custom Anaconda installer on Windows 10 64bit. I have created construct.yaml like :

name : TensorFlowEnv
version : 1.0.0
specs :
   - numpy
channels :
   - https://conda.anaconda.org/anaconda/win-64

After running the construcor command , I am getting the following error

platform: win-64
Collecting package metadata: done
Solving environment: done
Checking for duplicate files ...

Checking for 'C:\Users\Equip\Anaconda3\envs\TensorFlowEnv\NSIS\makensis.exe'
NSIS version: v3.01
Traceback (most recent call last):
  File "C:\Users\Equip\Anaconda3\envs\TensorFlowEnv\Scripts\constructor-script.py", line 10, in <module>
    sys.exit(main())

  File "C:\Users\Equip\Anaconda3\envs\TensorFlowEnv\lib\site-packages\constructor\main.py", line 221, in main
    dry_run=opts.dry_run)
  File "C:\Users\Equip\Anaconda3\envs\TensorFlowEnv\lib\site-packages\constructor\main.py", line 128, in main_build
    create(info, verbose=verbose)
File "C:\Users\Equip\Anaconda3\envs\TensorFlowEnv\lib\site-packages\constructor\winexe.py", line 218, in create
    preconda_write_files(info, tmp_dir)
  File "C:\Users\Equip\Anaconda3\envs\TensorFlowEnv\lib\site-packages\constructor\preconda.py", line 135, in write_files
    write_index_cache(info, dst_dir)
 File "C:\Users\Equip\Anaconda3\envs\TensorFlowEnv\lib\site-packages\constructor\preconda.py", line 40, in write_index_cache
    write_repodata(cache_dir, url)
  File "C:\Users\Equip\Anaconda3\envs\TensorFlowEnv\lib\site-packages\constructor\conda_interface.py", line 61, in write_repodata
    fh.write(raw_repodata_str)
TypeError: write() argument must be str, not None

The error is :

TypeError: write() argument must be str, not None

Any help would be appreciated.


Solution

  • I had this error and resolved it. First the steps taken to get this error:

    I was using a local conda server. I had gone into /envs/someenv/conda-bld and ran 'python -m http.server' in there, after doing a 'conda index .' in that folder. Which works. And in my construct.yaml I had 'http://localhost:8000' as a channel. This worked until I updated my conda package to a later version. It would not update in that conda channel.

    Now the steps to resolve the error:

    I did a 'conda clean -i', then manually had to delete all the repodata.json and index.html in that build folder. And deleted all the cache folders. And also in the win64 folde.r Then I did 'conda index .' and the index files and repodata generated where then all correct. Then once that was done I did conda construct again and the installer works.

    Note I have to force 'conda install conda=4.5.13 constructor=2.3.0' and NOT use constructor v3 and some later versions of conda as they build installers that look right but have missing files.