Hyperopt: ModuleNotFoundError: No module named 'hyperopt'

Created on 6 Aug 2019  路  6Comments  路  Source: hyperopt/hyperopt

I am facing very odd issue. Cannot import module with PyCHarm dubugger which is already installed. Installed with pip and via PyCharm. Enviroment set to default among all projects (not venv)

I can import module through default python IDLE and through PyCharm python console
I can run ui_main.py with cmd line.

Traceback (most recent call last): File "D:\Programs\PyCharm Community Edition 2019.1.3\helpers\pydev\pydevd.py", line 1758, in <module> main() File "D:\Programs\PyCharm Community Edition 2019.1.3\helpers\pydev\pydevd.py", line 1752, in main globals = debugger.run(setup['file'], None, None, is_module) File "D:\Programs\PyCharm Community Edition 2019.1.3\helpers\pydev\pydevd.py", line 1147, in run pydev_imports.execfile(file, globals, locals) # execute the script File "D:\Programs\PyCharm Community Edition 2019.1.3\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "E:/Programowanie/GitHub Repositories/lottoprediction/ui_main.py", line 8, in <module> from machine_learning import MachineLearning File "E:\Programowanie\GitHub Repositories\lottoprediction\machine_learning.py", line 4, in <module> from hyperopt import STATUS_OK, Trials, tpe, hp, fmin ModuleNotFoundError: No module named 'hyperopt'

pip list
Package Version


certifi 2019.6.16
chardet 3.0.4
cycler 0.10.0
decorator 4.4.0
future 0.17.1
helpdev 0.6.10
hpsklearn 0.1.0
hyperopt 0.1.2
idna 2.8
importlib-metadata 0.19
joblib 0.13.2
kiwisolver 1.1.0
lxml 4.4.0
matplotlib 3.1.1
networkx 2.3
nose 1.3.7
numpy 1.17.0
pandas 0.25.0
pip 19.2.1
psutil 5.6.3
pymongo 3.8.0
pyparsing 2.4.2
PyQt5 5.13.0
PyQt5-sip 4.19.18
PyQt5Designer 5.10.1
python-dateutil 2.8.0
pytz 2019.2
QDarkStyle 2.7
requests 2.22.0
scikit-learn 0.21.3
scipy 1.3.0
setuptools 41.0.1
six 1.12.0
sklearn 0.0
tqdm 4.32.2
urllib3 1.25.3
zipp 0.5.2

Another odd thing is that PyCharm intially found module (no underscore):
image

And I can access it by going declaration:
image

All 6 comments

I think I have a similar issue, I installed hyperopt with pip3, and have the following situation:

  • it works in the Python interpreter (i.e. python3 and writing from hyperopt import hp)
  • it works in VSCode's interactive mode (which uses jupyter)
  • it doesn't work when running a python file from the command line (i.e. python3 hypertest.py where hypertest contains an import). The error is

ModuleNotFoundError: No module named 'hyperopt.pyll'; 'hyperopt' is not a package

@janek / @MrDominikku can you confirm if you're using the same Python environment between each?

Typically its best practice to work with virtual environments when working with Python - PyCharm can make one on your behalf.

@dandxy89 I tried different approach for this case, I have used default environment in main python path c:\program files\python and created virtual enviro using pycharm. Also I have put full package in project directory and imported it as any other module, but it came with same error.

I can run project through terminal, but cannot debug it using pycharm :(

@dandxy89 thank you very much for responding. I don't use virtual environments, but I'm not entirely sure if there isn't something going on under the hood that I'm not aware of. I was able to reinstall and fix my problem in the meantime, I unfortunately don't have any useful info to help @MrDominikku

@MrDominikku I wonder if anyone has a hunch what the root cause of this could potentially be. there's nothing special about how hyperopt is packaged. did you see this before with another package?

I have same issue with imblearn package which I use for under-sampling in hyperopt cross_val_score. For debugging commenting out hyperopt, but it would be great to debug hyperopt step by step to learn more about it 馃槈

Was this page helpful?
0 / 5 - 0 ratings

Related issues

optroodt picture optroodt  路  4Comments

simonm3 picture simonm3  路  4Comments

peiyaoli picture peiyaoli  路  4Comments

ghost picture ghost  路  3Comments

c-phys picture c-phys  路  3Comments