ModuleNotFoundError: No module named 'pymc' - python

I am trying to us 'pymc' to run my code however i have a problem with it
first , i use anaconda to manage my pycharm , my anaconda show i have successfully install 'pymc'
and then i try to import the module to my project so does my pycharm shows 'pymc' have successfully installed

enter image description herecheck pycharm have numpy module
watch this https://youtu.be/dxwB8KBLMcs and follow steps form 0.51

You are running the wrong python interpreter in your command line. According to your PyCharm settings, your packages are installed for "D:\Anaconda\python.exe" and that is the python.exe that you should be calling. But according to your console output, executed interpreter is in another path.
In PyCharm, go to "Run" > "Edit Configurations" and make sure that the "Python interpreter" configuration there is also set to the one in "D:\Anaconda".
There also seems to be an issue that may be caused by PyCharm about the project settings. If the solution above does not work try the solution explained here:
https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000164624-SOLVED-pycharm-seem-to-fail-to-add-to-PYTHONPATH

Related

How to I fix the “ModuleNotFound” error when importing PyQt5? [duplicate]

I installed bottle on Python 3.4 with pip install. In the 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'
in your PyCharm project:
press Ctrl+Alt+s to open the settings
on the left column, select Project Interpreter
on the top right there is a list of python binaries found on your system, pick the right one
eventually click the + button to install additional python modules
validate
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":
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:
I am using Ubuntu 16.04. For me, it was the incorrect interpreter, which was by default using the virtual interpreter from the project.
So, make sure you select the correct one, as the pip install will install the package to the system Python interpreter.
PyCharm 2019.3, my solution is below:
For me, none of the above worked, and curiously even within one file some imports worked, some didn't:
from folder1.folder2.folder3.my_python_file import this_function # worked
from folder1.folder2.folder3.my_python_file import that_function # didn't work
Follow the above advice, but if it doesn't fix it additionally, (in PyCharm) click File >> Repair IDE and confirm all the 6 steps one after another.
I had virtual env site package problem and this solved it:
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/...)
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.

Import "flask" could not be resolved from source Pylance (reportMissingModuleSource)

When I am writing
from flask import Flask
One Yellow line is coming up under flask and stating Import "flask" could not be resolved from source Pylance (reportMissingModuleSource) . Also, I am able to do the work with this package also successfully. But the thing is, I am not able to use autosuggesstions for Classes and methods very well.
Further:
I have checked that flask is installed successfully.
Also I visited this thread https://github.com/microsoft/pylance-release/issues/236
And I set up my settings.json in vscode as follows:
"python.analysis.extraPaths": [
"/media/sarimurrab/New Volume/COURSES/Flask/FlaskMigrateforDatabaseMigrations/2"
]
But Still, unable to resolve the error.
When I did not install the module "flask" in the Python environment currently used in VSCode:
Please use the command "pip --version" to check the source of the module installation tool "pip", the module is installed at this location:
Then, we can use the command "pip show flask" to check the installation location of the module "flask": (It checks whether the installation location of the module is consistent with the Python environment displayed in the lower left corner of VSCode.)
If the "reportMissingModuleSource" message is still displayed here, please reload VS Code.
(F1, Developer: Reload Window)
Are you using a Virtualenv? If so make sure that VSCode is using the virtualenv as your python interpreter, otherwise it will not be able to pick up the packages that you installed inside this virtualenv.
To do so, click on the Python interpreter in your bottom bar, you should get a list of possible python interpreters including your virtualenv.
I had a similar issue while trying to import flask on vscode.
I fixed it by using anaconda. Simply you install the flask module in your created environment example screenshot.
How to create a virtual env in anaconda:
1. On the left sidebar, click on environments.
2. Click create (at the bottom).
3. At the pop-up window, give your vir.env a name
and select the language version.
4. Once created, you can start installing
different modules in your environment.
I hope that helps!
For Linux Mint and for those who have installed flask, but VSCode doesn't find it:
check the Flask path: pip show flask (should be smth like
Location: /home/<username>/.local/lib/python3.8/site-packages
in VSCode click left bottom button and choose the python interpreter, in my case I changed it from python3.9 to python3.8 as we can see it in the flask path.
That's because you have not chosen your path correctly,
type:
pipenv --venv
then it will show you where your virtual env is installed. Check where the packages are installed in your env, and then type what comes to you from the shell\scripts or whatever\python, and the packages will work.
I solved my problem by using a "Global" version of Python. Maybe Pylance had not updated to work with the version of Python I was using.
interpreter language screenshot
I was facing same issue. I tried all solutions from stack-overflow but none worked. But after lot of searching and time waste I found my silly mistake. I had created folder named 'flask' and stored my project there. I'm beginner and going through lot of such silly mistakes. Hope it would help, if somebody commits same mistake.
I think this is a Vscode problem ,just restart the Vscode .
By the following steps, I solved this issue:
1)On the project directory create the .flaskenv file
In the .flaskenv file write the following two lines:
FLASK_ENV=development
FLASK_APP=main.py
Please pay attention that main.py is my main file after writing flask run in the Vscode terminal, additionally, you have to create an env folder or requirement file proviosly.
A few answers (Jill's, Marius's, and Roy's) mention the fact that is necessary to choose the correct Python interpreter to make Pylance function properly. I would like to add the fact that this is still necessary to do when using a Jupyter Notebook with the correct Python kernel already chosen.
It is counterintuitive to choose both Python interpreter and notebook's Python kernel to make things work. It is even more counterintuitive considering the fact that Python interpreter's button (on the left bottom of the screen, on status bar) does not necessarily appear when a Jupyter Notebook is open, but when a Python script is open. For instance, in this screenshot, we see the little line under Scikit-learn's import, indicating a problem with the import (even though the import is successful). However, the correct Python kernel, with Scikit-learn installed, is already chosen. Only opening a Python script we notice that the Python interpreter is the reason of this behavior, because a wrong one is chosen, without Scikit-learn. In some sense, one could think that the reason behind this was a problem with the Python kernel or the Conda environment (it is common to experience this kind of problem when experimenting with Jupyter Notebook and Jupyter Lab). I hope this answer may help those who are searching for solving this problem in the specific context of Jupyter Notebooks inside VS Code. They could ignore the other answers because they could think it is not the case for them.

ModuleNotFoundError: No module named 'requests' (VS Code with Anaconda interpreter)

Hi I'm really new on the programming. I am using VS Code with Anaconda interpreter:
Here
I am using Windows 10
I want to import "requests" module on my VS Code. I opened cmd and wrote "pip3 install requests" but it told me "Requirment already satisfied:" etc... Then I tried to download with Anaconda. I opened my cmd and wrote "conda install requests" and I downloaded.
Then I wrote this code to try module: Here
But I received an error in VS Code like that: Here
What can I do to solve this problem? Thank you so much for your answers. (By the way, sorry for my bad English :D I hope I explained my problem.)
Click in bottom left cornet in VS code on (Python <Version>) and then choose the python version that in your system.
I have just found the answer. In VS Code, I open powershell and write "py (filename).py". But just now, I tried to click top-right button which name is "Run Python File in Terminal" (green button). Then code executed successfully. I didn't take an error.
Check the following prospects in vscode with python extension:
When selecting interpreter, press ctrl+shift+' to open a new integrated terminal. If you selected base:conda environment, the terminal should be like this:
Then use pip list to show modules you've installed, if module requests not there, type commands pip install requestsin the terminal;
click then create a launch.json file, select Python File. This creates and opens a launch.json. You can close it or add configurations you want. More guidance about debug configurations you can reference: Python debug configurations in Visual Studio Code. Press F5 to run your code.
Just make sure the module installation is in the same environment as interpreter you've selected.

Keyboard module installed but not detected

I am on MacOS and have installed the Keyboard module. It took a while to install the first time, but eventually it finished and, when I try running my script in Pycharm, I get ModuleNotFoundError: No module named 'keyboard'.
The first time I installed it was within Terminal with pip3. After that I tried with Git Clone and it told me that Keyboard was alredy installed. I know this to be correct because when I enter help("modules") into a Python window, it shows up on the list.
Edit: I have also tried restarting Pycharm
The problem is most probably in PyCharm's interpreter. You may try to reset the interpreter to your latest python3.
In this link (https://www.jetbrains.com/help/pycharm/configuring-python-interpreter.html), please see the section "Changing the project interpreter in the project settings".
Hope it works!

"ImportError: No module named cv2" when running Django project from PyCharm IDE

I'm running a Django project from PyCharm with the configuration set up to use the Python interpreter from a virtualenv which has a dependency on opencv. The site works fine locally when I run django-admin.py runserver, however I keep getting an "ImportError: No module named cv2" error when I try to run the project directly from the PyCharm IDE.
Has anyone else had this issue with PyCharm and opencv?
In the end I ended up having to set an environment variable directly in the Pycharm Edit Configurations -> Run/Debug Configurations -> Environment Variables panel. I added the following option after you hit the edit button: set name to PYTHONPATH and value to /usr/local/lib/python2.7/site-packages:$PYTHONPATH which should display in the input box after editing as PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH. Also, I made sure to log out and log back in of osx which also worked for a couple other path related issues.
I'm not quite sure if this works for you guys but it works for me. In my case, it seems to me that I installed OpenCV to work with the default Python arriving with OS X. I remember I tried to install Python 2.7.5 and Python 3 in my Mac as well, I see them when I chose my Python interpreter for Pycharm. And all of them didn't let me import module cv2. So I change to the default Python2.7.2 (/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python). Then, in File/DefaultSettings/Project Interpreter/Python Interpreter, click on the Python interpreter that's been added (Python 2.7.2), click on Paths and locate to "/usr/local/bin/python2.7/site-packages"and add it. Click the blue refresh button, apply and ok. Then it works, both with import and autocompletion.
Regards,

Categories