ipython console2 no module named Ipython - python

I've been using ipython notebook with console2 for a while now and recently installed a different version of python and now my console is giving me an error saying "No module named IPython". I think the path has been changed or something, but I don't know how to fix it. Any help is greatly appreciated!

I am pulling the answer out of the comments.
Point your PATH system variable to the correct version of Python. This is accomplished (on Windows) by going to System Properties -> Advanced -> Environment Variables. If you already have a Python directory in there, modify it to the correct, new path. Otherwise, append it to the end of the existing string. Do not remove what is already present.

If you are using anaconda for python the ipython installation is on "Scripts" folder
To get the console2 running with ipython you all have to do to start cmd in silent mode by configuring a new tab in the console2 settings window on win7
here is my config for the shell:
cmd.exe /k C:\Anaconda\python.exe "C:\Anaconda\Scripts/ipython-script.py"
for the startup dir i have just defined the workspace i am using:
D:\python-workspace

Related

Error on visual studio code: Python was not found; run without arguments to install from the Microsoft Store [duplicate]

I was trying to download a GUI, but the terminal kept giving me this error:
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.
I'm trying to install it using this command:
python -m pip install --upgrade pip setuptools virtualenv
Check your Python version and be sure it is installed on your machine
Check the path environment variable
Go to -> "start" and type "Manage App Execution Aliases". Go to it and turn off "Python"
I was having the same issue and I fixed it by using the below method.
Copy two paths of Python
C:\Users\Maninder\AppData\Local\Programs\Python\Python39
C:\Users\Maninder\AppData\Local\Programs\Python\Python39\Scripts
These are the paths where your Python interpreter is installed. Now add this path into your environmental
variable. Put this path into System variable, not in user variable. I was using user variable, so I was facing the issue.
I have a solution for you. Make sure you check the path mark during installation. Then you need to go to Manage App Execution Aliases.
Simply go to your search bar and search for Manage App Execution Aliases. You will find the attached screen and you need to turn off App Installers as you see on the screen. Also, see the path,,, follow Maninder's answer.
Then you are good to go! :)
I had the same issue. In Windows CMD, only: py --version, works.
I tried adding the path on System variables, and it didn't work. If you are using PyCharm as I do, try to run all commands from the IDE's terminal. It usually is on the side bar where the Run and the Console is. If it is not, go to: menu View → Tool Windows → Terminal. It worked just fine for me.
You need to download Python from https://python.org. When in the installation, be sure to check the option that adds Python to PATH.
I haven't gotten this error before and have been using Python a long time, and then suddenly it showed up. I think that it is a result of a Windows update designed to steer you to their store.
In any case: to remedy the problem, go to Settings → app execution aliases → and turn "off" Python. (What they tell you to do, in other words). This should resolve the problem.
If you have installed Python successfully with add python path, ticked on, and have added
C:\Users\<user>\AppData\Local\Programs\Python\Python39
C:\Users\<user>\AppData\Local\Programs\Python\Python39\Scripts
to the path into System variables and have turned off the "aliases" and they all didn't work, you can simply use python instead of python3 in your cmd command.
Check the Aliases for App Execution in Windows. Search for Alias App in your Windows toolbar to find the UI for this. Try turning off anything Python related.
Try adding the following to your "Path" environment variable:
C:\Users\Default\AppData\Local\Programs\Python\Python37
C:\Users\Default\AppData\Local\Programs\Python\Python37\Scripts
Replace Python37 with your own version.
I solved this problem for Visual Studio Code with just writing "python" in the console:
python
After that, Microsoft Store opens automatically with the Python app:
And I just click Get.
And it all work!
All the previous answers are correct, but in my case, I was getting this, because I was not passing the version...
The fix is passing the version:
py.exe -3 your_program
If you're on Windows, you may want to use the Python installer, in Windows Marketplace.
I faced the same error while using Anaconda and trying to link the Python executable path in the command prompt.
It got rectified by going to Settings → App execution aliases → and turning "off" Python. Then again I had to set the path for Python in Anaconda and was successful in executing "python --version" command.
The same thing happened to me even after trying all the above-mentioned steps.
I just restart my system and it was working fine. Do it and if still doesn't fix the issue then make sure you have checked "add python ( any version ) to PATH" before installing Python.
If none of the previous answers are working, you can check if you have the Python executable in your program files.
Go to C:\Program Files and check if you have the Python application. If not, go to the python download website here and download the .exe file.
While installing you must select "Custom install" and select the location as C:/Program Files.
Install it and it should work now from anywhere. This worked for me!
To sincerely resolve this issue, do the following:
Uninstall the Python instance and reinstall it. Note: Make sure you check
"Add variable PATH".
On the command line, type:
python -m pip install --upgrade pip setuptools virtualenv
I got this issue when I used Visual Studio Code as the IDE, and Anaconda as my Python compiler. And you don't need to close the "app alias" in settings, but copy your python.exe to python3.exe in your Anaconda folder.
That happened to me. So, to fix it, you have to follow the following steps:
Uninstall the Python version you already installed.
Go ahead and open the installation file to reinstall it again.
Before hitting Install Now, make sure to tick the box in front of Add Python to path.
Go ahead and complete the installation procedure as usual.
Steps for installing Python
The problem is more subtle than it seems.
For example, if you are using Visual Studio Code on the bottom left, you should see Python X.X.X xx-bit (the X is the version).
If you click in there you will see where the IDE is getting the python.exe from.
Locate that folder into your file explorer and then just follow the answer that is saying to change the environments variables.
So copy the path where python.exe is and add it to the Path variable and do the same where the Script folder is (it is in the same directory where the python.exe is).
Then of course make sure your IDE is using the right Python.
None of the answers here worked for me. I did this and the error went away.
For Windows 11 which I was using, I reran the python-3.10.5-amd64.exe file from my downloads directory and then chose to modify the installation.
Then I followed these easy steps.
Make sure the PIP component is checked before proceeding to install.
Then check 'Add Python to environment variables' if it's not checked already.
Proceed to Install.
At this point, your error will be solved
If you already have the Python executable on your machine and you are getting this error in Windows 10, search for the Python executable and copy its path then copy the path in system variables. It worked for me.
to check in windows
py --version
or restart your pc first then put htis command again

VS Code doesn't recognize Python Virtual Environment Packages - It shows red underlines

I installed python virtual env. I use vs code. I imported scrapy in my code and vs code doesn't recognize the module. Actually, it works well when I run it. scrapy crawl tester
Just, vs code shows red underlines that mean "Unable to import scrapy" So this is just vs code issue, not venv or scrapy package install issue.
This code works well and actuallay, scrapy is imported without any issue. This is just vs code issue. Thank you.
You might be able to solve your problem by using CTRL+Shift+P to add "Python: Select Interpreter" to your project.
If you created a virtual environment and activated it as well
type which python on macOS/Linux,
type where python on Windows,
inside the activated terminal session.
(env) userpc#pc:~$ which python
/home/userpc/Desktop/foldername/env/bin/python
In VSCode press Ctrl+Shift+P, under >Select Interpreter paste the location you receive using the former command.
Once done, restart VSCode.
VSCode will also ask you to install pylint in your environment and if it doesn't you can do the same by activating you environment and typing
pip install pylint
inside the activated terminal session.
Ran into the same problem - selected the correct Python interpreter in VS Code, pip installed all the desired Python libraries but import is still underlined in VS Code.
What you need to do
What worked for me is to make sure that the linter that you are using in this VS Code instance (I was using pylint) is from the bin folder of the virtual environment, not somewhere else.
How you can do it
I'll use the absolute path to the desired virtual environment /User/ProjectFolder/env as an example.
To check that you meet the conditions stated in What you need to do, toggle the settings.json file in VS Code by pressing ⌘ + ,:
Make sure that the correct Python interpreter is selected. i.e. "python.pythonPath":/User/ProjectFolder/env/bin/python3.
Make sure that the linter (e.g. pylint) is located in that bin folder, not anywhere else. i.e "python.linting.pylintPath":/User/ProjectFolder/env/bin/pylint, NOT something like "python.linting.pylintPath":/usr/local/bin/pylint.
This means that you have to install your desired linter in the virtual environment.
Hope this helps.
I tried #cleon-w's answer which worked for me. (Thanks Cleon)
I was using pyenv on my Mac M1 (Big Sur) with vscode. vscode could not resolve the
paths to python that the pyenv provides, so I looked within the pyenv scripts to find the absolute paths
to the underlying python and the pylint files.
As #Cleon W says I ensured pylint and python are in the same bin directory.
Then edit VS Code settings.json to point to them directly (bypass .pyenv) and the imports could be found.
settings.json (vscode)
"python.defaultInterpreterPath": "/Users/USERNAME/.pyenv/shims/python",
"python.pythonPath": "/Users/USERNAME/.pyenv/versions/3.9.1/bin/python",
I have similar problem with Django. What solved my problem was:
create .vscode/settings.json file inside root dir for project.
add this json {"python.defaultInterpreterPath": "path to bin directory in root dir for project"}
Ctrl-Shif-P -> Python: Select Interpreter -> select one that said: Use Python from python.defaultInterpreterPath. If it's not in the list, hit refresh (circled refresh button on the top of settings box).

How to resolve "Invalid Python interpreter name 'python.exe'!" error in PyCharm

I'm trying to add my Python interpreter to PyCharm but whenever I navigate to python.exe and click Ok it says Invalid Python interpeter name 'python.exe'! (the spelling mistake for interpeter is how it's spelled in the dialog that appears)
I installed Python through the Microsoft app store. The interpreter is located at ~\AppData\Local\Microsoft\WindowsApps\python.exe. This is the path I navigate to when selecting the interpreter in PyCharm. There are also python3.exe and python3.7.exe but those don't work either. I can run python from the command line and it behaves as expected.
I got the same error message when I imported a project of an existing virtual environment to pyCharm. Though the name and path of the exe was correct, pyCharm did not accept it.
My solution was to remove the Interpreter in pyCharm and to add it again. Then the Error was gone. Perhaps that can help someone ...
The EAP (Early Access Program) build Pavel suggests did not work for me. I hope this gets sorted out in PY-33406 as Pavel suggests.
In the responses for that issue, the thing that worked for me is included. I created a virtual environment using venv and was able to use that python interpreter. As it says on that page...
Open the windows prompt
Go to the project root: cd X:\path\to\project
Type python -m venv venv
Chose "existing interpreter" instead of
creating a new venv using Pycharm and pick the Python binary from the
virtualenv you created in the previous step
Hope that helps, happy to update this to add more detail if not.
Remove the interpreter (by using minus sign) and add it again!
In case anyone else is still facing this issue, reinstalling PyCharm did the trick for me.
If you're adding an already existing virtual environment, it may sound dumb but check that the python executable does exist. If it's a symlink, it should point to a valid location in your system.
In my case, I had overwritten the already existing python executable with a new python executable created by clicking the "new" option in the virtual environment creation by mistake, and the result was an incomplete virtual environment setup in which the python executable was a symlink to a non-existing python executable. Recreating the virtual environment from scratch and using it as an "existing" virtual environment solved the issue.
I know these are basic checks, but hopefully this helps someone out there who rushed for an answer.
Try PyCharm 2019.2 EAP build. The problem should be fixed: https://youtrack.jetbrains.com/issue/PY-33406 (or better use Python from python.org).
I reported the typo to PyCharm's bug tracker, thanks https://youtrack.jetbrains.com/issue/PY-36686

Adding Python 2.7 & 3.x Interpreters to PyCharm

I'm having issues adding a project interpreter to PyCharm from a new Anaconda environment. I have Anaconda2 installed with one Python 2.7 environment (C:\Anaconda2\python.exe) that I've been using on Pycharm without issue for several months.
I am attempting to add a second Python 3.6 interpreter (from C:\Anaconda2\envs\py36\python.exe) to my PyCharm. After adding the Local Interpreter to Pycharm, I run into a MS Visual C++ Runtime Error R6034 "An application has made an attempt to load the C runtime library incorrectly".
From cursory googling, it seems that there could be a runtime DLL conflict (potentially msvcr90.dll) between Python 2 & 3. All fixes I see involve editing the executable path of the application, but I don't think this is feasible for my Pycharm use case. How do I get rid of this error, or just generally be able to use both Python 2 & 3 interpreters through my PyCharm?
I think that's the problem with Anaconda and different msvc dll in the computer.
You can test the conda command in the command line, to see if R6034 happens. If it happens, try the following solution:
I had a similar problem with Anaconda3 and Python27. I solved this problem via executing the following command in cmd, outside of any conda environment:
conda install msvc_runtime
After installing the packages, open a new command and test if the R6034 error still appears.
I had a similar issue and was able to resolve it by selecting:
File --> Invalid Caches / Restart...
from PyCharm's main menu.
You may also want to double check that any Conda Environments that you have defined as Python Interpreters in PyCharm are properly configured per the docs
This issue was absolutely maddening. Million R6034 error windows would just keep popping up one after another if I just wanted to get help on a function. I researched it for months, on/off, opened tickets with JetBrains to no avail.
If you need to have multiple versions of Anaconda, and if you have Anaconda paths in your PATH, before launching PyCharm, delete all Anaconda paths from PATH, and then start PyCharm. You need to create a separate wrapper launcher script for PyCharm to fix PATH before PyCharm is started. Note that alternative of starting PyCharm and then fixing interpreter and python console PATHS inside PyCharm do not really work. Because PyCharm may be using a system path to access python to read documentation etc. So the only clean fix is to fix the system PATH before PyCharm starts.
Once you understand what needs to be done, then you can use your own steps/tools. This worked for me:
Create a script that modifies PATH. I used Python for that, sed or any other tools are fine too. The script simply examines each path element and removes it if it refers to Anaconda, and then puts it back together:
path_cleanup.py:
path_old = os.environ['PATH']
path_python_removed = [loc for loc in path_old.split(pathsep) if not ('python' in loc or 'Ana' in loc)]
print(pathsep.join(path_python_removed))
Create Powershell script to fix PATH and start PyCharm from that clean environment. To find PyCharm path, the simplest is to start it up the usual way, and head to Task Manager, right mouse click on pycharm64.exe process and select "open file location" to get the full path.
pycharm_clean.ps1
$Env:Path=python path_cleanup.py # call the script to fix the PATH
start-process $PYCHARM_PATH\pcharm64.exe -WindowStyle Hidden # enter your full path to pycharm and put it into background.
You can create a shortcut to launch pycharm_clean.ps1 + you can add it to your windows start up folder to be launched upon login: %APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup\
If you use BASH inside Cygwin, then steps for path clean up require a bit more tuning, but nothing you cannot do. If you need help, put a comment and I can add that script as well.

tput: terminal attributes: No such device or address in Windows Pycharm debugger

I am getting a red message every time I use the console from the debugger and try to see the output of a pandas object
"tput: terminal attributes: No such device or address"
I am using PyCharm 2016.3.2 and according to me I didn't update anything - it just started to appear all of a sudden. I attach a screenshot of the debugger with info on my ipython and debugger versions. Would appreciate your help to understand how to get rid of this message. It seems to appear both in the Python Console and Debugger Console, but not in the PyCharm Terminal. Thanks.
There is a workaround inside PyCharm itself without affecting the rest of the system:
You can hard code PATH as part of Environment set up under this menu:
Click menu Run -> Edit/Configurations...
when the configuration window opens, click on Defaults -> Python.
On the right side under Environment Variables hard code PATH without git/cygwin. See below how to get that path from cmd prompt
import os, re; print ';'.join([p for p in os.getenv('PATH').split(';')
if not re.search('Git', p)])
This PATH variable seems to overwrite system's path variable.
Image of these steps overlaid in PyCharm.
Another workaround is to simply move tput to a different cygwin PATH directory,
e.g. if tput is in ~/git-for-windows/usr/bin, and the same directory is in the windows PATH, moving tput.exe to ~/git-for-windows/usr/local/bin will fix the issue in pycharm and still work within cygwin
Have you installed git or cygwin recently? If so, try to delete git or cygwin related paths from system environment variable PATH. If had the same problem as you and now have fixed it by doing so.
Just to complement the answer from H.J. Liu, if you are unable to delete cygwin from the system PATH, then it is probably in the user PATH. Please see this related post Unable to remove cygwin from PATH environment variable
additional for Anaconda2 Users, you will find tput.exe in following two path:
Anaconda2\Library\usr\bin
Anaconda2\pkgs\git-xxx\Library\usr\bin
mv them to xxx\usr\local\bin
My colleague had the same error. It occurred only for pandas.
We resolved it by changing the project interpreter in PyCharm to the anaconda one, where he previously set up everything else. If for example, you use Anaconda navigator, then all the tput paths are set up there. (Maybe the settings got lost when downloading a new PyCharm version.)
I'm sharing this to give people some more ideas where to look for, not to get too focussed on cygwin.

Categories

Resources