Own installed package not available in Spyder - python

I'm beginner in python, and I have to maintain a python code, which imports a self-made package.
I am able to install this package with pip, but somehow the Sypder(pyhton 3.9) does not accept it.
The error is: "ModuleNotFoundError: No module named 'myModule'
If I type the following command into the IPython console, then it says that the package is already installed.
pip install d:\MyFolder\myModule-0.2.0-py3-none-any.whl
Result:
Processing d:\MyFolder\myModule-0.2.0-py3-none-any.whl
myModule is already installed with the same version as the provided wheel. Use --force-reinstall to force an installation of the wheel.
Note: you may need to restart the kernel to use updated packages.
I already tried to solve this problem based this article: Spyder_modulenotfound
The packge is present in the Anaconda3 installation folder: d:\Anaconda3\Lib\site-packages\myPackage-0.2.0.dist-info\ and I added this folder into the PYTHONPATH manager tool. Already restarted the Spyder many times, still no change.
What am I missing? Please help...

Related

"No module named 'sympy'" Error. Problem occurs after installation

I am new to Python.
I am trying to use the Sympy package.
I am running Python 3.11 in Pycharm
I am using Windows 10.
It displays:
ModuleNotFoundError: No module named 'sympy'
I ran pip install sympy, it installed it. And when I try reinstalling it, it displays:
Requirement already satisfied: sympy in c:\users\jrk\appdata\local\programs\python\python311\lib\site-packages (1.11.1)
Requirement already satisfied: mpmath>=0.19 in c:\users\jrk\appdata\local\programs\python\python311\lib\site-packages (from sympy) (1.2.1)
I tried going through this guide
https://bobbyhadz.com/blog/python-no-module-named-sympy
but it did not work.
I tried uninstalling it and reinstalling it
both with pip and mpip
it unfortunately didnt work
at the top you can see which interpreter i am using
I can see that there is a file called sympy in my downloads folder, maybe that has to be relocated, but where to?
My instructions might be a bit rusty as I don't regularly use Windows for Python but here goes:
You'll notice that the path to your Pycharm Python interpreter (c:\Users\jrk\PycharmProjects..) is different than the path reported by pip in your error messages (c:\Users\jrk\appdata..).
It's perfectly normal to have multiple versions of Python around, but you'll need to be a bit careful about which one you're invoking.
It's unclear from your description where exactly you are running the pip commands, but usually if you open built-in terminal in Pycharm, it most likely has the right virtual environment activated automatically. The command line prompt should begin with (venv) if that is the case. If you then run pip install sympy you ought to have it installed in the correct place.
If you're using a regular command prompt, you can also manually activate the virtual environment by running the activate or activate.bat file that you'll find in c:\Users\jrk\PycharmProjects\pythonProject\venv\Scripts\ folder.
Might want to also read a bit about virtual envs # https://docs.python.org/3/library/venv.html
I found the solution. I do not know why it worked. But i moved the project from the local file on my computer to the server we use in our company, and then it worked
Try Uninstalling it and reinstalling
pip uninstall sympy
pip install sympy

ModuleNotFoundError: No module named 'mysql' continuously occuring in VS Code despite multiple attempts to resolve

I seem to be facing this error continuously despite:
Installing the mysql-connector via "python -m pip install mysql-connector-python"
Installing the MySQL package via "pip install MySQL"
I have confirmed that I have installed the package as it says "Requirement already satisfied everytime I run it again in the terminal". Additionally, I have tried installing and reinstalling the package as well.
But all the results are the same. Each time I run my script and try to "import mysql.connector", I always get the ModuleNotFoundError: No module named 'mysql' error
Would greatly appreciate some help. Thank you very much
Do you use virtual environments? If it is a virtual environment, please copy the contents in the expansion package folder of the virtual environment to the package folder under python.
If you have two versions of Python in your system, you may also encounter this problem. "CTRL+SHIFT+P" and choose the correct interpreter.
You can use the following method to check and see where pip installed the package:
pip show MySQL

Python3 module not found error after installation with pip3

I have been stuck on a module not found error of python3.
I have a VM on Microsoft Azure, a Centos 7. Then I installed python3 and pip3, and some packages I needed. But there’s one package that I just couldn’t find after I installed it
sudo pip3 install --user stockstats
But whenever i wanted to run a python script using this package, there’s
ModuleNotFoundError: No module named 'stockstats'
What I tried:
pip3 show stockstats
As I really want to see where it was installed. It shows nothing. What it is supposed to do is like this:
Name: openpyxl
Version: 3.0.7
Summary: A Python library to read/write Excel 2010 xlsx/xlsm files
Home-page: https://openpyxl.readthedocs.io
Author: See AUTHORS
Author-email: charlie.clark#clark-consulting.eu
License: MIT
Location: /usr/local/lib/python3.6/site-packages
…
Then I guess it might be something wrong with the installed path, so I uninstalled the package, and then did
sudo pip3 install stockstats --install-option="--prefix=/usr/local/lib"
(I am just guessing if openpyxl is installed there then stockstats should be there too, as python imported openpyxl successfully)
That didn’t work as well, the error still persists.
*I didn’t use any package manager other than pip3.
** some irregularities occurred when I was trying to use python3(see this post). It was resolved, but I am not sure if the error in this post is related to that.
Any help or hint would be appreciated ;)
Thanks all for the prompt reply.
After Guo Lei’s comment, I tried downloading the tar ball for this package and installing it myself without pip, which eventually told me what exactly happened: a module named int-date, required by stockstats, was not installed in the python library directory. After I installed it in the proper directory, the issue is resolved.
As Danila Vershinin and phd had pointed out, I really shouldn’t run pip as root, and that is the source of issue(curiously, however, that only one particular module required by stockstats is installed in /root/.local/lib/. All others are in the right place, maybe I added the prefix flag without remembering it...?)
Still, I am not sure, I ran pip using sudo because I received permission denied errors repeatedly — so should I use something like sudo --user? Or sth else?
This works for me.
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple stockstats
or
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
pip install stockstats
You can visit This website for Installing pip in centos 7 Pip Install In Centos 7
for maybe some errors in installing pip.
reinstall python.
check that the module name is correctly typed
install stockstats in pip like "pip install stockstats" (getten from pypi.com)

Python not recognizing newly installed or some already satisfied modules

I have noticed that when I install new modules using pip install example, it installs correctly but when I try importing it in a script it says: ModuleNotFoundError: No module named 'example'. To get the modules working I have to copy the module's folder to the directory of my script. Before this started happening I had installed some modules which also work now so I'm a bit confused.
I'm guessing that there's something wrong with some PATH but I'm not really sure. How can I fix this?
Edit: I'm almost 100% sure that these problems started happening when I installed Anaconda. I have made sure Anaconda's folder is added to PATH but I still have the same issue.
With Anaconda, you would benefit from installing new packages by conda install example instead of using pip.
However, it is likely that you have installed another copy of Python that comes with Anaconda, and you should check which Python you are using by typing python -V in your command prompt or checking where it is installed (for Windows machines, check here). You might have installed the package to use with one version of Python, but your system directed you to the other one.
I have uninstalled my standalone Python distribution after installing Anaconda, so my default version of Python is the version that comes with Anaconda.

I have installed the package from github but when importing module name not found

I'm trying to use this github repo!
but as soon as I import the package: from pykernels.basic import RBF
the following error is displayed:
ModuleNotFoundError: No module named 'basic'
I have double checked everything given my understanding of python, packages and how anaconda works but I don't know very much. The site-packages are in the path, the evn has the package and the init seems to be alright. I am really lost, if someone could tell me what I'm doing wrong or what else might be done to resolve this? Thank you!
for installation:
pip install git+https://github.com/gmum/pykernels#egg=pykernels
If you have installed both anaconda and original python, you will have two pip installed in your computer. The original python will have it's pip in \Python37\Scripts, and anaconda will have it's in \Users\admin\Anaconda3\Scripts. Your problem is that you used pip that is in \Python37\Scripts, the original pip. The original pip will install into the original python site-packages, not Anaconda's site-packages.
The solution is to make sure you're using Anaconda's pip when installing packages for use with Anaconda.

Categories