Can't Access CSV files using Pandas in Spyder - python

For some weird reason, Anaconda on my Mac got uninstalled and since I installed it again, I've not been able to access the files/datasets that I had accessed earlier.
Here are the screenshots:
I'm able to access the same files in PyCharm IDE but I've not been able to do so in Spyder. It'd be great if someone can help me with this.
Thanks in advance.

Related

Can't solve "No module named 'numpy'" after hours of digging

I know this is a problem that's been asked here before, but I have tried all the solutions I found and not solved it. It's possible I'm not understanding the solutions, but I have tried my best.
I am teaching myself Python and it is slow going, so I don't understand a lot yet. I'm using VSCode as an IDE, Python version 3.10, and Windows 10. I only have the Python extension installed for VSCode. My project files are on a flash drive, D. I replaced a couple folder names with [Default Names] in the text below.
I keep trying to debug/run some code in VSCode and the very first line
import numpy as np
gives me the error
Exception has occurred: ModuleNotFoundError - No module named 'numpy'.
But I know that's not true:
`PS D:\0-Career\Programming\PythonCoding\[ProjectFolder]> py -m pip install numpy
Requirement already satisfied: numpy in c:\users\[UserID]\appdata\local\programs\python\python310\lib\site-packages (1.23.1)`
I tried the solution of going to
environment variables > system variables > "Path" > edit > new >
c:\users\[UserID]\appdata\local\programs\python\python310\
as well as
C:\Users\[UserID]\AppData\Local\Programs\Python\Python310\Lib\site-packages\
and
C:\Users\[UserID]\AppData\Local\Programs\Python\Python310\Scripts\
and I also tried adding a user variable called Python. Nothing appears to have changed as a result of these additions.
Some history if it's helpful:
I first started by installing Python using the Microsoft Store. I used IDLE for a bit, and I used my command line to install pip and numpy. They worked for a little while. I later installed Visual Studio Code IDE. I ultimately have uninstalled the Microsoft Store version and installed the application from the Python site for Windows instead. I have also uninstalled and reinstalled it several times trying to fix my issues, and same for numpy. I also searched my C drive for "python" and burned everything from the past couple days and reinstalled and repaired it out of desperation. No luck.
I have tried to the best of my ability to uninstall everything and reinstall everything to start fresh, because numpy worked ever so briefly early on in IDLE, I think until I had installed the web download version of Python. I don't really understand environment variables, so I'm not sure what I'm doing or if I'm doing that wrong, or what needs to be restarted when I try something new, so it's possible I missed something.
Answers a 10 year old could understand would be appreciated! Or terminology I can easily research for an explanation of how to do it.
Ctrl+Shift+P open Command Palette
choose Python:Select Interpreter
Choose the right interpreter
Go to https://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy
Also Check 64 bit or 32 bit
Download the latest version
and open the location where you downloaded the NumPy module now press the 'SHIFT' key and press right-click on the mouse then a menu will open where you find open PowerShell. open it now PowerShell window opens in the folder now type pip install and the file name and press the TAB button and click enter. then the NumPy module will be installed.
Have Fun
Try adding the variable PYTHONPATH to your system variables and add the following paths to this variable.
C:\PATH_TO_YOUR_PYTHON_INSTALL
C:\PATH_TO_YOUR_PYTHON_INSTALL\DLLs
C:\PATH_TO_YOUR_PYTHON_INSTALL\Lib
C:\PATH_TO_YOUR_PYTHON_INSTALL\Scripts
It should look something like this.
Screenshot of Environment Variables
After you added the variable restart your VS Code and it should work.
I hope this helps.

VSCode Jupyter not connecting to python kernel

Launching a cell will make this message appear: Connecting to kernel: Python 3.9.6 64-bit: Activating Python Environment 'Python 3.9.6 64-bit'. This message will then stay up loading indefinitely, without anything happening. No actual error message.
I've already tried searching for this problem, but every other post seem to obtain at least an error message, which isn't the case here. I still looked at some of these, which seemed to indicate the problem might have come from the traitlets package. I tried to downgrade it to what was recommended, but it didn't solve anything, so I reverted the downgrade.
The main problem here is that I have no idea what could cause such a problem, without even an error message. If you think additional info could help, please do ask, I have no idea what could be of use right now.
Not sure what did the trick but downgrading VSCode to November version and after that reinstalling Jupyter extension worked for me.
i've just found out it's solved by simply just right clicking on code.exe, set to 'run as administrator', and done.
If anyone has the same problem, before reinstalling VSCode as the accepted answer said, try closing and reopening VSCode first.
That worked for me, saving me the agony of having to reinstall VSCode.
I am using mac.os. I moved vscode from the download folder to the application folder. This solved my problem.
On the VSCode download page, there are two Windows installer types: 'User Installer' and 'System Installer'.
I had VSCode installed in AppData folder, using user installer. On the OP's problem occurrence, I tried to restart, reinstall and downgrade VSCode, as other answers suggested, but nothing helped.
Finally, I tried with System Installer. It requires elevated privileges during installation and installs VSCode in Program Files folder. That solved the problem for me.
So, one may try with different installation type.
None of the previous answers are working for me (windows 10 + python 3.10.9 + VSCode x64-1.74.3). What made things work was downgrading VS Code. I arbitrarily chose VSCode x64-1.66.2

Why won't basic code execute in Jupiter (import pandas as pd)?

I just downloaded Anaconda on a new laptop (have used Python many times before), and I currently can't run any code in Jupiter Notebooks. I am stuck in [*] no matter how simple the code (i.e. import pandas as pd or say x=1). Any suggestions on how to fix this? So far I have tried restarting Anaconda and shutting down the code in the running tab.
Based on the logs, take a look at this related question. Otherwise, googling python3 ERROR:tornado.general:Uncaught exception in ZMQStream may help.
I found the answer. The solution is not anywhere on stack overflow or Google. The answer to this problem is only on YouTube, which I found slightly surprising. Essentially, I had two versions of Anaconda, because it would seem that Macs come with an older version of Anaconda already installed in a hidden file called opt. I had to locate this file and then delete it in the terminal. Once Anaconda was completely removed, I was able to re-download Anaconda and then Jupyter was able to launch smoothly.
For anyone else having this problem you can find the solution here: https://www.youtube.com/watch?v=SJ_JTgq8-m8

Anacaonda/Windows 10 - ModuleNotFoundError: No module named 'scipy'

I recently updated Anaconda (Spyder (Python 3.6), Windows 10). Several of my libaries disappeared and had to be re-installed. However, I have been unable to reinstall scipy. When I run "conda install scipy -f" from the Windows PowerShell, scipy seems to be reinstalled. However even if I close Spyder and restat Windows, I continue to get the error: ModuleNotFoundError: No module named 'scipy'.
I know that problems similar to this one have been posted previously, but I have been unable to find anything that seems to fix the problems.
Thanks in advance for any advice (and apologies if this question was posted yesterday as well).
I battled with this same issue. The reason is most likely because you already have a file in the current directory called scipy.py. For example, when I first started with scipy, i made a file literally called scipy.py to practice in. Then, when I tried to import scipy from a different file, the first instance of 'scipy.py' was my practice folder, rather than the actual package which was further into the directory.
I advise you check for folders that you may have named scipy.py that aren't the actual scipy package. I could be wrong, but it seems likely that python will first search the folder it saves your files to, and then trundle over to the packages folder saved elsewhere.
Hopefully this helps some other folks who are stumped by the same issue!

Gurobipy ImportError in PyCharm

When trying to run my code in Pycharm i get this error:
from .gurobipy import *
ImportError: libgurobi80.so: cannot open shared object file: No such file or directory
In the regular python terminal i can import gurobipy with no problem. How can Pycharm be fixed?
I've read the install instructions and posted the following 3 lines at the end of the bashrc file with a text editor.
export GUROBI_HOME="/opt/gurobi800/linux64"
export PATH="${PATH}:${GUROBI_HOME}/bin"
export LD_LIBRARY_PATH="${GUROBI_HOME}/lib"
Reinstalling PyCharm (even switching to EDU and Professional) as well as reinstalling Ubuntu did not change the error. Please help.
I had the same error and configured PyCharm on Kubuntu by adding the environment variables to the run config.
Select Edit configurations... and add the variables to the Environment variables field. In my case, I added GUROBI_HOME, LD_LIBRARY_PATH and GRB_LICENSE_FILE. Also, I had to enter the values directly: LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GUROBI_HOME/lib didn't work, but LD_LIBRARY_PATH=/path/to/gurobi/lib works.
Code completion and suggestions still don't work, but at least I can run from PyCharm now.
I went around this problem by just editing the file in PyCharm and running it via the terminal. I didn't find another solution so far, so I'm still proceeding this way. It seems to be a PyCharm-specific problem.
I tried more than 10 ways to install Gurobipy in Pycharm. However, there is no way to use.
There are two days to use Gurobipy
Jupyter based on Conda - installation : recommended by Grobipy.
Install Grobipy indirectly to python (This Is what i did for my setting)
Hope Pycharm and Gurobipy to work together to resolve this issue. But most people might use Jupyter these days. So don’t know how much they will be interested in fixing this.

Categories

Resources