简体   繁体   中英

unable to import module on GCP VM instance

I'm new to google cloud platform: I've pip installed the python mip module on the VM instance. However, when I tried to import the module, I got the following error:

import mip
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/yl4536/anaconda3/lib/python3.5/site-packages/mip/__init__.py", line 2, in <module>
    from mip.solver import Solver
  File "/home/yl4536/anaconda3/lib/python3.5/site-packages/mip/solver.py", line 9, in <module>
    class Solver:
  File "/home/yl4536/anaconda3/lib/python3.5/site-packages/mip/solver.py", line 292, in Solver
    e1: Union["mip.LinExpr", "mip.Var"],
  File "/home/yl4536/anaconda3/lib/python3.5/typing.py", line 537, in __getitem__
    dict(self.__dict__), parameters, _root=True)
  File "/home/yl4536/anaconda3/lib/python3.5/typing.py", line 494, in __new__
    for t2 in all_params - {t1} if not isinstance(t2, TypeVar)):
  File "/home/yl4536/anaconda3/lib/python3.5/typing.py", line 494, in <genexpr>
    for t2 in all_params - {t1} if not isinstance(t2, TypeVar)):
  File "/home/yl4536/anaconda3/lib/python3.5/typing.py", line 185, in __subclasscheck__
    self._eval_type(globalns, localns)
  File "/home/yl4536/anaconda3/lib/python3.5/typing.py", line 172, in _eval_type
    eval(self.__forward_code__, globalns, localns),
  File "<string>", line 1, in <module>
AttributeError: module 'mip' has no attribute 'Var'

I've successfully imported the module on both my local machines and google colab. I would really appreciate if someone could give me some directions on what I should look into in order to fix this.

Thank you in advance!

To resolve this I installed this on the GCP VM (Ubuntu) instance as per this doc .

1- pip install mip

2- /usr/bin/python3 -m pip install --upgrade pip

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM