'ImportError: No module named 'bottle' - PyCharm

I installed bottle on python3.4 with pip install. In terminal, when I do:

$ python3.4
>>>import bottle # shows no import error
>>> 

but when I do it in PyCharm, it says "import bottle ImportError: No module named 'bottle'"



Solution 1:[1]

In some cases no "No module ..." can appear even on local files. In such cases you just need to mark appropriate directories as "source directories":

Mark as source lib directory

Solution 2:[2]

The settings are changed for PyCharm 5+.

  • Go to File > Default Settings
  • In left sidebar, click Default Project > Project Interpreter
  • At bottom of window, click + to install or - to uninstall.
  • If we click +, a new window opens where we can decrease the results by entering the package name/keyword.
  • Install the package.
  • Go to File > Invalidate caches/restart and click Invalidate and Restart to apply changes and restart PyCharm.

    Settings

    Install package

Solution 3:[3]

I am using Ubuntu 16.04. For me it was the incorrect interpretor, which was by default using the virtual interpretor from project.

So, make sure you select the correct one, as the pip install will install the package to system python interpretor.

enter image description here

Solution 4:[4]

pycharm 2019.3 ,my solution is below: enter image description here

Solution 5:[5]

I had virtual env site package problem and this helped me, maybe it will help you too enter image description here

Solution 6:[6]

In the case where you are able to import the module when using the CLI interpreter but not in PyCharm, make sure your project interpreter in PyCharm is set to an actual interpreter (eg. /usr/bin/python2.7) and not venv (~/PycharmProject/venv/...)

Solution 7:[7]

I had the same problem, I tried all fixes like installing from the project interpreter and installing from python console, nothing worked. What worked was just going to the project folder from the terminal and installing it from there.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ivan Talalaev
Solution 2
Solution 3 Vikas Goel
Solution 4 MarsYoung
Solution 5 ibrahim mert
Solution 6 Bruce Leat
Solution 7 Hakun