coin-or / pulp

A python Linear Programming API

Home Page:http://coin-or.github.io/pulp/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MOSEK in one Conda environment causing error in another

haochenz96 opened this issue · comments

Details for the issue

What did you do?

I have two Conda environment:
snakemake- I set up this one first and had been using it without issue. It does not have MOSEK solver in it.
aa - I recently set up this environment, and MOSEK was installed.

After aa is set up and MOSEK installed into it, I have the following error while trying to import pulp in snakemake:

>>> import pulp
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/juno/work/iacobuzc/haochen/mambaforge/envs/snakemake/lib/python3.11/site-packages/pulp/__init__.py", line 34, in <module>
    from .pulp import *
  File "/juno/work/iacobuzc/haochen/mambaforge/envs/snakemake/lib/python3.11/site-packages/pulp/pulp.py", line 99, in <module>
    from .apis import LpSolverDefault, PULP_CBC_CMD
  File "/juno/work/iacobuzc/haochen/mambaforge/envs/snakemake/lib/python3.11/site-packages/pulp/apis/__init__.py", line 7, in <module>
    from .mosek_api import *
  File "/juno/work/iacobuzc/haochen/mambaforge/envs/snakemake/lib/python3.11/site-packages/pulp/apis/mosek_api.py", line 32, in <module>
    class MOSEK(LpSolver):
  File "/juno/work/iacobuzc/haochen/mambaforge/envs/snakemake/lib/python3.11/site-packages/pulp/apis/mosek_api.py", line 40, in MOSEK
    env = mosek.Env()
          ^^^^^^^^^
AttributeError: module 'mosek' has no attribute 'Env'

What did you expect to see?

What did you see instead?

Useful extra information

My guess is that perhaps I installed MOSEK into the base environment and had to remove it and reinstall into aa, or have some environment variables set or that I have the MOSEK license at ~/mosek/mosek.lic, MOSEK is detected by pulp in snakemake but imported as an empty script (per this issue https://groups.google.com/g/mosek/c/MB_-kH-mSaQ).

I changed this line to:

    except (ImportError, AttributeError):

And it seems to have solved the error.

The info below often helps, please fill it out if you're able to. :)

What operating system are you using?

  • Windows: ( version: ___ )
  • Linux: ( distro: CentOS 7 )
  • Mac OS: ( version: ___ )
  • Other: ___

I'm using python version:

  • 2.7
  • 3.4
  • 3.5
  • 3.6
  • Other: 3.11

I installed PuLP via:

Did you also

If I understand the error there, you need to rename the file so it's not mosek. You're confusing python with modules that have the name of libraries.