How to install Python packages for use with Spyder without Anaconda - python

I've been trying to lean Python and trying to find a good Python coding environment. Spyder seemed to be quite powerful. Though I having problems installing non-default packages. I have to install them in the default environment using pip, since I'm using LabVIEW to connect to python and for now LabVIEW only support the default environment path.
In Spyder I have specified the the Python root folder: C:\Users<user>\AppData\Local\Programs\Python\Python37-32. The user environment Windows key also contains this path.
I continue to get the "ModuleNotFoundError: No module named 'impedance'" error message. According to this post, this method should work, but no luck so far.

Related

No module named 'odf' due to wrong Python version

I have many different versions of Python, but a version that I use and that terminal show me if use command Python – version is 3.10.0.
When I use command pip list I got a big list of library, including the one I recently installed odfpy.
I open VsCode, choose Python version 3.10.0 and try to import odf but...
ModuleNotFoundError: No module named 'odf'
For sure I need to set something on VsCode or change some configuration in Linux but I cannot find a normal explanation of how to solve this issue.
If I change the Python version in VsCode with 3.8.10, odfpy (and also Django just installed) is recognized. So I suppose that, even if the Python version selected on the terminal is 3.10.0, when I pip install something, is installed on version 3.8.10. How do you manage this?
Please check which pip you are using through the command of pip --version.
After you switch the python interpreter in the VSCode, please create a new terminal, and make sure it has activated the environment you have selected.
I also use VS code and use Python 3.10 and i had try to download the odfpy which has gone alright, i use the command python -m pip install odfpy
try and see if it work for you though.
If it does not work, maybe try and create a virtual environment if you haven't created it yet.
In my case i was getting same error while using import-export django module. Installing odf library didn't worked got same error. I resolve this issue by simply pip install tablib==0.14.0.

Failure importing openpyxl in Spyder 5.1.5

So I am trying to open a.xlsc file in Spyder using pandas. After importing pandas as pd, when using pd.read_excel() command in the console, it showed the error:
ImportError: Missing optional dependency 'openpyxl'. Use pip or.....
Then I installed the module with:
pip install openpyxl
successfully in CMD, but again Spyder shows the same error.
I tried to restart the kernel, close and reopen Spyder, and even restarted my machine to no avail.
Openpyxl is listed in both help ("modules") in python shell as well as in pip list in CMD.
When I tried to import the openpyxl itself in Spyder (import openpyxl)it says "Module not found error: No module named "openpyxl"."
I have only python 3 (3.9) not both 2 & 3 and Spyder is the only IDE I use with python.
I apologize if this question sounds stupid, I'm fairly new to Python.
I would appreciate any help regarding this.
Thank you.
Spyder has its own Python interpreter 3.7.9 so it loads only the modules installed for that Python.
Since I had a separate Python 3.9.7 installation, whenever I used pip via CMD it installed all the modules for the 3.9.7 Python, that's why my Python terminal & CMD were able to list openpyxl but Spyder said it isn't installed.
After ransacking through the internet I switched the Spyder interpreter to the 3.9.7 stand-alone installation by Tools > Preferences > Python interpreter > Use the following interpreter > navigate through your directory and select the stand-alone python 3.7.9 .exe. Afterwards, Spyder said "Your Python environment or installation doesn't have the spyder‑kernels module or the right version of it installed. Use pip install spyder-kernels==2.1. to install..."*. So back to CMD, I installed the spyder-kernels and now everything's fine.
Spyder IPython console shows Python 3.9.7 (Used to be 3.7.9, Spyder's own interpreter). Now I'm able to import openpyxl without any issues.
I had the same issue as Anoban, but the answer provided by Anoban didn't work for me. I was able to resolve it in two ways
1. Changing my Python environment
This is the better, quicker answer IMO. My Spyder environment was somehow using a custom Python environment as its default (see picture).
Once I changed the Python environment (Tools > Preferences> Python interpreter) from "Default" to the following path (it should have been the default Python interpreter in the first place IMO):
"C:\Users\username\miniconda3\python.exe"
...it worked (see image below to what it should look like in the IDE).
I still had to do an install of spyder-kernels=2.3 (see the next point in my post if you have trouble with that)
2. Creating a separate Python environment
I got this way to work before I figured out the method described in #1 above, so I am posting it too, since it may help someone.
I used the help provided on the Spyder website, followed the directions provided on their site exactly, and it worked for me.
FYI, my installation is slightly different than Anoban's - I didn't use pip. I installed miniconda and a stand-alone version of Spyder on my Windows machine. I used the Anaconda prompt as the terminal window, not the Windows Command Prompt.
Hope this helps someone.
update: when I changed the Python interpreter to the new environment, the Python console gave me the following error
The Python environment or installation whose interpreter is located at
C:\Users\rebecca\miniconda3\python.exe
doesn't have the spyder‑kernels module or the right version of it installed (>= 2.3.0 and < 2.4.0). Without this module is not possible for Spyder to create a console for you.
You can install it by activating your environment (if necessary) and then running in a system terminal:
conda install spyder‑kernels=2.3
But it couldn't find the correct channels for installation so I needed to use
conda -c conda-forge spyder-kernels=2.3
then it worked.
#rpinto73
I know it's tad late. I'm wondering how my answer differs from yours lol.
We faced the same issue and came up with the same solutions. The difference is you set the Python interpreter in a conda environment as default in Spyder whereas I set my standalone Python installation as default. Thus we both assigned an external Python interpreter to be used inside Spyder. Since the external interpreters we assigned (a global Python interpreter in my case (that's why I used pip) and a Python interpreter inside a conda virtual environment in your case (so you had to use conda, you could use pip inside a conda virtual environment as well but not a good practice since it could break dependencies) didn't have the spyder-kernels module we had to install it manually.
The major issue with Spyder is it is an IDE WRITTEN in Python. Thus it needs a Python interpreter to load & function; which is the reason for it being painfully slow during loading. Spyder packs some mundane data science libraries like pandas, numpy, scipy with itself, which you make use of when using Spyder's default Python interpreter. However Spyder does not allow users to manually install packages for its default interpreter (as far as I know). Which makes sense since any conflicts in dependencies introduced by users manually installing/upgrading packages might break the functionality of Spyder itself, making it dysfunctional. Thus the best solution is to leave the Spyder's interpreter to Spyder itself and use a custom Python interpreter where we can install and upgrade modules as we please!.
And a free advice, it's okay to use Spyder when you are starting out with Python as beginners, but it is useless when you have to do heavy computations. You will mostly find yourself facing memory errors. It is lightweight IDE best for learners & beginners. It's best to switch to a more general yet capable development environments like Visual Studio Code, Jupyter Lab.. or a full-fledged Python IDE like PyCharm (there is a free community edition) if you want the in-IDE variables pane & plots pane. But be warned PyCharm (generally any IDE from JetBrains) is notorious for having massive memory footprints.

PyCharm venv issue "pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available"

I would like to use PyCharm to develop in Python. I have looked around but do not seem to be able to find any solutions to my issue.
I have Python 3 installed using the Windows msi. I am using Windows 10. have downloaded PyCharm version 2019.3.1 (Community Edition). I create a new project using the Pure Python option.
On trying to pip install any package, I get the error:
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available
If I try this in VSCode using the terminal it works fine.
How can I resolve this issue? It would appear to be a problem with the virtual environment but I do not know enough to resolve the issue.
Sorry guys, it appears the basic interpreter option was on Anaconda, that I had installed sometime ago , forgotten about and it defaulted to it . Changing my basic interpreter option to my Python install (Python.exe) solved the issue.
Keep on learning

trouble with importing python modules

I am trying to import Python packages that I had previously installed but I keep getting this error when trying to import it
"ImportError: No module named gdal"
In the images attached (in the link :P) you can see that the package python-gdal and python-numpy are installed. I am also attaching the python output.
P.S = I am using Ubuntu and running python from the terminal.
You have possibly installed a non-Ubuntu version of Python - Anaconda - yet these packages are installed into the system Python. You should probably remove Anaconda, and/or run the system Python explicitly as /usr/bin/python.

Robot Framework can't find Python

I'm trying to install Robot Framework, but it keeps giving me an error message during setup that "No Python installation found in the registry." I've tried running the installer as administrator, I've made sure that Python is installed (I've tried both 2.7.2 and 2.7.9), and both C:\Python27 and C:\Python27\Scripts are added to the PATH (with and without slashes on the end, if that matters).
I have no idea why it can't find Python. What do I need to do?
Try to add the following path in environment variable also:
"C:\Python27\Lib\site-packages"
Since this path consists all the third party modules installed on your PC and also verify if robot-framework library is present in this folder.
I faced the same issue.
Install a different bit version of ROBOT framework. In my case, I was first trying to install 64bit version but it said "No Python installation found in the registry."
Then I tried to install the 32bit version of ROBOT framework and it worked.
So there is nothing wrong with your Python version.

Categories

Resources