I am coming from a VScode background , and for my recent project (on Deep Learning) I am having to manage huge code files in Spyder (Version 3), and I am not seeing any option of code folding?
I am not willing to switch to another IDE , as Spyder is very productive for my project.
Please suggest any hack to do it , if it is not there in the Spyder codebase.
(Spyder maintainer here) You can install the first beta of Spyder 4 to get code folding.
If you use Anaconda, you need to use the following commands:
conda update anaconda
conda update spyder
or if you use pip, then you need to run
pip install -U --pre spyder
This beta is quite stable and it has been tested for more than a year.
Spyder 4.0.1 is released, which supports code folding.
If you are using anaconda, use
conda update --all
to get it.
If you want to fold more that just a loop or a function, you can also try:
#%%
Code that you want to fold
#%%
Related
I'm new in programming, actually I use it for Machine Learning.
I have installed python and anaconda (I don't know if that is right, or I have to install only anaconda?).
And I can see in start menu: (Anaconda powershell, Jupyter, Spyder, Anaconda navigator, Anaconda prompt).
So my question is: Do I still have to use vscode as IDE, or one of the listed programs that come with anaconda? If the answer is the second choice, I will ask, which one of them?
Thanks.
I'm using python just because I have a project in ML, So I must to set the necessary things for ML, like libraries, dataset, and algorithms. Then I have to learn how to use them.
Any help will be very apprecheated.
Anaconda is a Python distribution, that not only comes with Python itself, but a lot of additional Python packages from the "scientific stack", like numpy, pandas, matplotlib, scipy, scikit-learn: exactly what you need for ML. You don't have to install anything else from python.org.
Anaconda also comes with the Spyder IDE. This is the perfect choice for a Python beginner. You don't need VSCode. VSCode is way more flexible than Spyder, but you have to get used to it.
Conda is the package manager that comes with Anaconda. Do yourself a favour an learn some conda basics and how to use virtual environments here: https://conda.io/projects/conda/en/latest/user-guide/getting-started.html
The important difference between Anaconda and pure Python is that you have to activate a conda environment - even the "base" environemnt - before you can use it. This is not obvious to a beginner.
If I were you I would use vcscode. Anaconda is only a python with extra features, but to code you would appreciate the VSCOde. It comes with many features and you can install extensions to burst your experience. Go for it.
I am using Spyder with Anaconda on macOS. I have already updated Anaconda and Spyder to version 4.2.0 (4.2.1 was not found). The problem is now, that if I am typing in Spyder it takes about one second until the letters appear, which is very annoying. Is there somebody who also has this problem? Or does somebody have a suggestion on what might be the problem?
Had the same exact issue with Spyder 5.0.0, on Catalina; editor being very laggy (the console was fine).
Solution worked for me: Disable Kite!
From the top menus:
Python > Preferences... > Completion and linting,
Deselect any option that calls Kite:
Notify me when Kite can provide missing completions (but is unavailable!)
Enable Kite provider
PS: Tried pyqt solutions with no success (this now generates warnings in the terminal every time I open Spyder).
(Spyder maintainer here) There are two main causes of this problem:
We had several memory leakages and other serious inefficiencies that were causing a lot of sluggishness in the editor. Most of them are fixed in our 5.1.5 version, released in September 2021. Other improvements will come in 5.2.0, to be released in November 2021.
If you're still experiencing this problem with those versions, it could be because you're in Big Sur. The only way to get a fix for that is by using our mac OS installer
I'd like to chime in and say I'm getting this on Catalina (not Big Sur).
Using Spyder 5.0.5 seemed to fix it.
-- Edit
No it didn't. I'm on Catalina and it's still laggy as hell. Using v5.0.5
read: https://github.com/spyder-ide/spyder/issues/14218
One solution suggests downgrading pyqt and pyqtwebengine.
vancromy commented on 17 Nov 2020 I just pip installed pyqt==5.12 and pyqtwebengine=5.12 in my base conda environment and noticed a
substantial decrease in the latency! Still a bit of latency but not as
pronounced as before. :)
Note: Please don't use this solution if you're using Anaconda because it could break your environments.
tools -> reset spyder to factory defaults
and it worked
Two years later, and this is still an issue. Sypder recommends installing from their DMG, which resolves the issue.
What I did was create my virtual environment and instead of installing Spyder there, I installed:
conda install spyder-kernels=2.2
v2.2 is important because otherwise there may be conflicts and it won't install.
Then, deactivate your environment and launch Spyder from the conda base environment.
In the bottom right of Spyder is text with the environment name. For example, mine says: conda:base(Python:3.9.12)
Click that and then "Change default environment in Preferences"
In the Preferences frame, under Python Interpreter, select Use the Following Python Interpreter
From the drop down menu, select the one with the name of your environment. It should look something like:
/Users/YourComputerName/opt/anaconda3/envs/environmentname/bin/python
Click Apply, then okay.
Spyder works flawlessly when you install its standalone version and not from the anaconda distribution (not sure why anaconda is still not fixing it).
If you want to make use of conda virtual environment with Spyder standalone IDE, see the solution detailed below. It worked for me very well.
https://medium.com/#apremgeorge/using-conda-python-environments-with-spyder-ide-and-jupyter-notebooks-in-windows-4e0a905aaac5
# install Anaconda and create a new conda environment
conda create -n env_name python=3.7.4
# activate environment
conda activate env_name
conda install package_name
# get path of the environment
python -c “import sys; print(sys.executable)”
# install spyder-kernels (version >= 2.3.0 and <= 2.4.0)
pip install spyder-kernels
# copy the env path in Spyder IDE and restart Spyder IDE
Spyder -> preferences -> python interpreter -> use the following Python interpreter -> choose from the drop-down list or copy the env path
Experienced this issue on MacOS Mojave via Anaconda. Upgrading both Anaconda (v4.10.3) and Spyder (v5.0.5) didn't help. Ended up following this guide, which suggested upgrading PyQt5 and PyQtWebEngine modules. A warning was produced upon upgrading:
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
spyder 5.0.5 requires pyqtwebengine<5.13, which is not installed.
spyder 5.0.5 requires pyqt5<5.13, but you have pyqt5 5.15.4 which is incompatible.
Despite the incompatibility warning, I no longer experience latency.
Note: Please don't use this solution if you're using Anaconda because it could break your environments.
Due to Anaconda didn't support free for commercial use. So I downloaded Spyder IDE from Spyder official website.
Spyder official web
Since Spyder IDE doesn't provide a function for users to download libraries as PIP install. But I still love Spyder's UI and some functions, especially, variable explore, etc...
So I installed official python on my PC, taking Spyder IDE as a code editor. <-- It can work by changing the python interpreter in the Spyder preference setting.
But I found an error when I try to open a variable (which is dataframe) on variable explorer, others are work well.
from pandas import DataFrame
People_List = ['Jon','Mark','Maria','Jill','Jack']
df = DataFrame (People_List,columns=['First_Name'])
print (df)
I got the same error and I noticed that I only got it after I created GeoDataFrames from the Geopandas library. Once I restarted Spyder, as long as I don't create a GeoDataFrame, it opens all other DataFrames (from Pandas) just fine.
I had the same issue and setup (windows 10, trying to install and get geopandas to work, but then couldn't get dataframes to be viewed in spyder). Ultimately, running pip install spyder in the new python that I was trying to use in spyder fixed the problem.
However, I think probably switching to an anaconda-based python interpreter in spyder, and installing geopandas and spyder-kernels through conda, would be a better long-term approach. This also has worked for me (I think I have become confused between pip and conda, e.g. this answer re: geopandas asks for pip https://stackoverflow.com/a/58943939/5233269, but conda can also install geopandas -- and most importantly deal with all the dependencies involved. I think conda is probably better long-run for data work.)
I'm trying to use Tensorflow in Pycharm, I have selected the Python interpreter Anaconda in the setting, and I have added the package Tensorflow but it doesn't seem working. Plus I did the installation with the Anaconda prompt writing pip install tensorflow but it still not working and obtain this error:
No module named 'tensorflow'
Someone could help me? Thank you so much
Tensorflow can be a bit of a pain to install, the process is completely different if you are doing it outside anaconda so I won't go into that.
This documentation is particularly helpful and what I have used to get tensorflow working on my own pc
https://docs.anaconda.com/anaconda/user-guide/tasks/tensorflow/
If you are doing cpu only stuff in tensorflow then running this in an anaconda command prompt will create an env for you to work on tf.
conda create -n tf tensorflow
conda activate tf
If you want to use your GPU with tensorflow then you need to check various things such as windows and linux will only support CUDA 10.0 for tensorflow 2.0. That being said you can use the following to set up a GPU env:
conda create -n tf-gpu tensorflow-gpu
conda activate tf-gpu
Be aware that this may not result in a working env depending on your GPU ect, So I would recommend that you refer to this page: https://www.tensorflow.org/guide/gpu
As a personal side note: I would highly recommend using jupyter lab when organising and running machine learning tasks as you can split up codes into cells with markdown decriptions of what occurs in cells which I find really helpful for readability and organisation.
guys,
here's the problem. I have got access to a server with jupyter notebook. There are already several packages installed on this server, which I want to use. But unfortunately it doesn't work with all packages. E.g. pandas, numpy and others work but I have problems with sklearn and Tensorflow.
When I query the list of all installed packages via pip I see for example the installation of Tensorflow:
If I want to import the package I receive this message:
It's the same with sklearn. Other packages work. Since there are still several people working on this server I wouldn't like to reinstall packages or restart the server. Does anybody have an idea where my mistake is?
Thanks a lot and stay healthy!
There could be multiple versions of Python installed on the server.
And the version that pip is using does not have to be the same version as your notebook is running.
So first, check which version of Python your notebook is using; Open the File menu and click on New console for notebook. In the console you should see the Python version. Say it shows this:
Python 3.7.6
Then call python3.7 -m pip list to see which modules are actually installed for that version of Python.
Edit
Is there an easy way to tell only my juptyer notebook to take this version?
Use Change Kernel... from the Kernel menu.