RasaHQ / rasa

πŸ’¬ Open source machine learning framework to automate text- and voice-based conversations: NLU, dialogue management, connect to Slack, Facebook, and more - Create chatbots and voice assistants
https://rasa.com/docs/rasa/
Apache License 2.0
18.91k stars 4.63k forks source link

ModuleNotFoundError: No module named 'randomname' #10792

Closed ShabbirK52 closed 2 years ago

ShabbirK52 commented 2 years ago

Rasa Open Source version

3.0.6

Rasa SDK version

No response

Rasa X version

No response

Python version

3.8

What operating system are you using?

Windows

What happened?

i used conda to create a virtual env for which i used the command: conda create --name rasa_project python==3.8 ujson tensorflow==2.6

after that i activated the env and installed rasa using: python -m pip install rasa

when i use rasa init to initialize the project, i get the following error.

Command / Request

rasa init

Relevant log output

(rasa_project) F:\pc\BEPROJECT>rasa init
Welcome to Rasa! πŸ€–

To get started quickly, an initial project will be created.
If you need some help, check out the documentation at https://rasa.com/docs/rasa.
Now let's start! πŸ‘‡πŸ½

? Please enter a path where the project will be created [default: current directory]
? Directory 'F:\pc\BEPROJECT' is not empty. Continue? Yes
Created project directory at 'F:\pc\BEPROJECT'.
Finished creating project structure.
? Do you want to train an initial model? πŸ’ͺ🏽 Yes
Training an initial model...
Traceback (most recent call last):
File "F:\pc\miniconda3\envs\rasa_project\lib\runpy.py", line 192, in _run_module_as_main
return run_code(code, main_globals, None,
File "F:\pc\miniconda3\envs\rasa_project\lib\runpy.py", line 85, in run_code
exec(code, run_globals)
File "F:\pc\miniconda3\envs\rasa_project\Scripts\rasa.exe_main.py", line 7, in
File "F:\pc\miniconda3\envs\rasa_project\lib\site-packages\rasa_main.py", line 121, in main
cmdline_arguments.func(cmdline_arguments)
File "F:\pc\miniconda3\envs\rasa_project\lib\site-packages\rasa\cli\scaffold.py", line 238, in run
init_project(args, path)
File "F:\pc\miniconda3\envs\rasa_project\lib\site-packages\rasa\cli\scaffold.py", line 132, in init_project
print_train_or_instructions(args)
File "F:\pc\miniconda3\envs\rasa_project\lib\site-packages\rasa\cli\scaffold.py", line 64, in print_train_or_instructions
training_result = rasa.train(
File "F:\pc\miniconda3\envs\rasa_project\lib\site-packages\rasa\api.py", line 103, in train
from rasa.model_training import train
File "F:\pc\miniconda3\envs\rasa_project\lib\site-packages\rasa\model_training.py", line 6, in
import randomname
ModuleNotFoundError: No module named 'randomname'
sara-tagger commented 2 years ago

Thanks for raising this issue, @samsucik will get back to you about it soon✨

Please also check out the docs and the forum in case your issue was raised there too πŸ€—
samsucik commented 2 years ago

@ShabbirK52 I gave this a quick try on a Macbook and, even though I didn't encounter the bug that your reported, things broke for me during rasa init after I installed tensorflow==2.6 via conda. More specifically, after I ran:

conda create --name rasa_project python==3.8 ujson
conda install -c conda-forge tensorflow==2.6

I wasn't able to train the initial model. Without installing tensorflow this way, and letting the rasa package properly install tensorflow as its dependency during python -m pip install rasa, everything worked. Therefore, I think you could try to rule out this cause of issues by creating an environment without tensorflow. If that still results in the bug you reported, we'll have to dig deeper.

ShabbirK52 commented 2 years ago

@ShabbirK52 I gave this a quick try on a Macbook and, even though I didn't encounter the bug that your reported, things broke for me during rasa init after I installed tensorflow==2.6 via conda. More specifically, after I ran:

conda create --name rasa_project python==3.8 ujson
conda install -c conda-forge tensorflow==2.6

I wasn't able to train the initial model. Without installing tensorflow this way, and letting the rasa package properly install tensorflow as its dependency during python -m pip install rasa, everything worked. Therefore, I think you could try to rule out this cause of issues by creating an environment without tensorflow. If that still results in the bug you reported, we'll have to dig deeper.

I just tried that and i still run into the same issue. I first cleared the conda cache using conda clean -a after which i created a fresh env, then i activated that env using conda activate -p PATH. I then installed python using conda install python==3.8 and then upgraded the pip version using python -m pip install --upgrade pip after which i installed rasa using python -m pip install rasa and then initialized my proj in my desired folder using python -m rasa init.

here is the log output:

Welcome to Rasa! πŸ€–

To get started quickly, an initial project will be created.
If you need some help, check out the documentation at https://rasa.com/docs/rasa.
Now let's start! πŸ‘‡πŸ½

? Please enter a path where the project will be created [default: current directory]
? Directory 'F:\SHABBIR\BE' is not empty. Continue? Yes
Created project directory at 'F:\SHABBIR\BE'.
Finished creating project structure.
? Do you want to train an initial model? πŸ’ͺ🏽 Yes
Training an initial model...
Traceback (most recent call last):
  File "F:\SHABBIR\BE\env\lib\runpy.py", line 192, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "F:\SHABBIR\BE\env\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "F:\SHABBIR\BE\env\lib\site-packages\rasa\__main__.py", line 139, in <module>
    main()
  File "F:\SHABBIR\BE\env\lib\site-packages\rasa\__main__.py", line 121, in main
    cmdline_arguments.func(cmdline_arguments)
  File "F:\SHABBIR\BE\env\lib\site-packages\rasa\cli\scaffold.py", line 238, in run
    init_project(args, path)
  File "F:\SHABBIR\BE\env\lib\site-packages\rasa\cli\scaffold.py", line 132, in init_project
    print_train_or_instructions(args)
  File "F:\SHABBIR\BE\env\lib\site-packages\rasa\cli\scaffold.py", line 64, in print_train_or_instructions
    training_result = rasa.train(
  File "F:\SHABBIR\BE\env\lib\site-packages\rasa\api.py", line 103, in train
    from rasa.model_training import train
  File "F:\SHABBIR\BE\env\lib\site-packages\rasa\model_training.py", line 6, in <module>
    import randomname
ModuleNotFoundError: No module named 'randomname'

after which i ran the command python -m pip freeze | findstr randomname and this is the log output for that: randomname==0.1.5

samsucik commented 2 years ago

@ShabbirK52 this is very interesting. As I still can't reproduce it, I passed it on to others who should be able to help you more. Let's see, it might be something Windows-specific...

tayfun commented 2 years ago

@ShabbirK52 Can you run pip show randomname so we can check location of where randomname is installed? I wonder if rasa cannot find randomname because they are in different environments (perhaps one in global, other not)? We can already see where rasa is installed from the traceback.

tayfun commented 2 years ago

Also another idea, can you remove everything inside directory F:\SHABBIR\BE\env\lib\site-packages\ which starts with randomname and reinstall it again? eg. if it exists, directory randomname/, randomname-0.1.5-py3.8.egg-info/ and any randomname.pth files?

ShabbirK52 commented 2 years ago

here

(F:\SHABBIR\BE\env) C:\Users\Shabbir>python -m pip show randomname
Name: randomname
Version: 0.1.5
Summary: Generate random adj-noun names like docker and github.
Home-page: https://github.com/beasteers/randomname
Author: Bea Steers
Author-email: bea.steers@gmail.com
License: MIT License
Location: f:\shabbir\be\env\lib\site-packages
Requires: fire
Required-by: rasa
ShabbirK52 commented 2 years ago

Also another idea, can you remove everything inside directory F:\SHABBIR\BE\env\lib\site-packages\ which starts with randomname and reinstall it again? eg. if it exists, directory randomname/, randomname-0.1.5-py3.8.egg-info/ and any randomname.pth files?

there was one directory called "randomname-0.1.5.dist-info", i deleted that and then ran these commands:

(F:\SHABBIR\BE\env) C:\Users\Shabbir>python -m pip show randomname
WARNING: Package(s) not found: randomname

(F:\SHABBIR\BE\env) C:\Users\Shabbir>python -m pip install randomname
Collecting randomname
  Using cached randomname-0.1.5-py3-none-any.whl
Requirement already satisfied: fire in f:\shabbir\be\env\lib\site-packages (from randomname) (0.4.0)
Requirement already satisfied: six in f:\shabbir\be\env\lib\site-packages (from fire->randomname) (1.15.0)
Requirement already satisfied: termcolor in f:\shabbir\be\env\lib\site-packages (from fire->randomname) (1.1.0)
Installing collected packages: randomname
Successfully installed randomname-0.1.5

(F:\SHABBIR\BE\env) C:\Users\Shabbir>f:

(F:\SHABBIR\BE\env) F:\>cd SHABBIR\BE\

(F:\SHABBIR\BE\env) F:\SHABBIR\BE>python -m rasa train
Traceback (most recent call last):
  File "F:\SHABBIR\BE\env\lib\runpy.py", line 192, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "F:\SHABBIR\BE\env\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "F:\SHABBIR\BE\env\lib\site-packages\rasa\__main__.py", line 139, in <module>
    main()
  File "F:\SHABBIR\BE\env\lib\site-packages\rasa\__main__.py", line 121, in main
    cmdline_arguments.func(cmdline_arguments)
  File "F:\SHABBIR\BE\env\lib\site-packages\rasa\cli\train.py", line 59, in <lambda>
    train_parser.set_defaults(func=lambda args: run_training(args, can_exit=True))
  File "F:\SHABBIR\BE\env\lib\site-packages\rasa\cli\train.py", line 91, in run_training
    training_result = train_all(
  File "F:\SHABBIR\BE\env\lib\site-packages\rasa\api.py", line 103, in train
    from rasa.model_training import train
  File "F:\SHABBIR\BE\env\lib\site-packages\rasa\model_training.py", line 6, in <module>
    import randomname
ModuleNotFoundError: No module named 'randomname'

The error still persists.

tayfun commented 2 years ago

@ShabbirK52 that is weird. I'm sorry I'm running out of ideas. Maybe system path for searching libraries is garbled and that's why randomname cannot be found? Can you run python -c 'import sys; print(sys.path); print(sys.executable); import randomname'?

ShabbirK52 commented 2 years ago

python -c 'import sys; print(sys.path); print(sys.executable); import randomname'

(F:\SHABBIR\BE\env) F:\SHABBIR\BE>python -c "import sys; print(sys.path); print(sys.executable); import randomname"
['', 'F:\\SHABBIR\\BE\\env\\python38.zip', 'F:\\SHABBIR\\BE\\env\\DLLs', 'F:\\SHABBIR\\BE\\env\\lib', 'F:\\SHABBIR\\BE\\env', 'F:\\SHABBIR\\BE\\env\\lib\\site-packages']
F:\SHABBIR\BE\env\python.exe
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'randomname'
tayfun commented 2 years ago

This confirms Python env cannot import randomname (not only Rasa) and I can see that 'F:\\SHABBIR\\BE\\env\\lib\\site-packages' is in the sys.path and we know previously that pip told us randomname was installed in location f:\shabbir\be\env\lib\site-packages. Windows file paths are case insensitive so I'm at a lost why randomname cannot be imported.

ShabbirK52 commented 2 years ago

This confirms Python env cannot import randomname (not only Rasa) and I can see that 'F:\\SHABBIR\\BE\\env\\lib\\site-packages' is in the sys.path and we know previously that pip told us randomname was installed in location f:\shabbir\be\env\lib\site-packages. Windows file paths are case insensitive so I'm at a lost why randomname cannot be imported.

yes that's right. What do you suggest i should do? i tried creating and env using python 3.7 as well but i am getting a different error there. While training the model, it says that a different version of numpy is expected than the one that is installed.

tayfun commented 2 years ago

yes that's right. What do you suggest i should do? i tried creating and env using python 3.7 as well but i am getting a different error there. While training the model, it says that a different version of numpy is expected than the one that is installed.

With latest Rasa numpy of 1.19.2 and larger is needed. Does installing numpy manually fix 3.7 problem?

For 3.8 maybe trying randomname without Rasa to see what could be the reason for the problem would be helpful? If you create a new 3.8 environment and pip install randomname, can you import it from Python shell? If yes, I would check how and where randomname files are. I would also try running rasa init from another directory (not virtual env root but from a user dir like bot-projects just in case paths are somehow getting mixed up (this might happen if current dir is added to the path and then there is another file called randomname for example).

ShabbirK52 commented 2 years ago

yes that's right. What do you suggest i should do? i tried creating and env using python 3.7 as well but i am getting a different error there. While training the model, it says that a different version of numpy is expected than the one that is installed.

With latest Rasa numpy of 1.19.2 and larger is needed. Does installing numpy manually fix 3.7 problem?

For 3.8 maybe trying randomname without Rasa to see what could be the reason for the problem would be helpful? If you create a new 3.8 environment and pip install randomname, can you import it from Python shell? If yes, I would check how and where randomname files are. I would also try running rasa init from another directory (not virtual env root but from a user dir like bot-projects just in case paths are somehow getting mixed up (this might happen if current dir is added to the path and then there is another file called randomname for example).

I have created two envs, one is in the env dir in miniconda folder created using conda create -n env_name and then used python -m rasa init in another folder but the error still persists. the other env was in an env folder in parent dir in which i tried to initialize my rasa project.

for python 3.7, i used python -m pip install --upgrade numpy which changed numpy version to one which isn't supported by rasa so i uninstalled it again using python -m pip uninstall numpy and then reinstalled it using python -m pip install numpy==1.19.2 but my error wasn't resolved. i didn't install numpy as a separate dependency and allowed rasa to install all dependencies itself by python -m pip install rasa so i don't understand why i am getting that error in the first place.

tayfun commented 2 years ago

for python 3.7, i used python -m pip install --upgrade numpy which changed numpy version to one which isn't supported by rasa so i uninstalled it again using python -m pip uninstall numpy and then reinstalled it using python -m pip install numpy==1.19.2 but my error wasn't resolved. i didn't install numpy as a separate dependency and allowed rasa to install all dependencies itself by python -m pip install rasa so i don't understand why i am getting that error in the first place.

Sounds like a similar error to randomname πŸ€” If you run python -c 'import numpy; print(numpy.__version__)' does it show you version 1.19.2 that have been installed? What's the exact error message saying?

ShabbirK52 commented 2 years ago

for python 3.7, i used python -m pip install --upgrade numpy which changed numpy version to one which isn't supported by rasa so i uninstalled it again using python -m pip uninstall numpy and then reinstalled it using python -m pip install numpy==1.19.2 but my error wasn't resolved. i didn't install numpy as a separate dependency and allowed rasa to install all dependencies itself by python -m pip install rasa so i don't understand why i am getting that error in the first place.

Sounds like a similar error to randomname πŸ€” If you run python -c 'import numpy; print(numpy.__version__)' does it show you version 1.19.2 that have been installed? What's the exact error message saying?

you pointed out the fact that the paths were same but they were just in different cases which made me think what would happen if i created a directory which was only in small case to initialize my proj. Though this seemed strange, it worked. The env that i had created using python 3.7 seems to work as of now without any error. I tried the same with python 3.8 and but that didn't seem to work.

ShabbirK52 commented 2 years ago

for python 3.7, i used python -m pip install --upgrade numpy which changed numpy version to one which isn't supported by rasa so i uninstalled it again using python -m pip uninstall numpy and then reinstalled it using python -m pip install numpy==1.19.2 but my error wasn't resolved. i didn't install numpy as a separate dependency and allowed rasa to install all dependencies itself by python -m pip install rasa so i don't understand why i am getting that error in the first place.

Sounds like a similar error to randomname πŸ€” If you run python -c 'import numpy; print(numpy.__version__)' does it show you version 1.19.2 that have been installed? What's the exact error message saying?

I fidgeted a bit with my env and found out that python doesn't recognize only the latest version of randomname for some reason. If i downgrade the version to 0.1.4, it works just fine. However rasa requires a version that is >=0.1.5 and hence other things fail when i try to initialize the rasa.

ShabbirK52 commented 2 years ago

for python 3.7, i used python -m pip install --upgrade numpy which changed numpy version to one which isn't supported by rasa so i uninstalled it again using python -m pip uninstall numpy and then reinstalled it using python -m pip install numpy==1.19.2 but my error wasn't resolved. i didn't install numpy as a separate dependency and allowed rasa to install all dependencies itself by python -m pip install rasa so i don't understand why i am getting that error in the first place.

Sounds like a similar error to randomname πŸ€” If you run python -c 'import numpy; print(numpy.__version__)' does it show you version 1.19.2 that have been installed? What's the exact error message saying?

I tweaked my env a lot and finally found a way through. I created a fresh env with python 3.9 then installed randomname and checked if python was able to recognize it. Once that was successful, I then downgraded python to 3.8 and rechecked if it could recognize randomname. It worked. After that i installed rasa using python -m pip install rasa and everything works like a charm so far.

samsucik commented 2 years ago

Wow, this blows my mind. I'm glad you got it to work @ShabbirK52!

ShabbirK52 commented 2 years ago

Wow, this blows my mind. I'm glad you got it to work @ShabbirK52!

Thank you for patiently helping me out, much appreciated πŸ™Œ