I'm a newbie to PyCharm and Jupyter. After installing Anaconda, I changed PyCharm project interpreter to Anaconda's python.exe, then I deleted the old virtual env folder where my Jupyter used to run (due to very limited disk space).
Now when I run Jupyter, it shows the following error message:
Error running 'python': Cannot run program "C:\my_work_dir\venv\Scripts\python.exe" (in directory "C:\my_work_dir\python"): CreateProcess error=2, The system cannot find the file specified
I understand the error message means that it cannot find the path. But I don't understand why it keeps looking for the old path while I have changed my project interpreter's path. Please help!
You need to install jupyter for the project interpreter or the venv you use as follow:
pip install jupyter
Note: This is what I suspect is the problem because Anaconda has
all this installed by default but for manual python install you need
to install all this packages(for ipython is required jupyter) in
order to have it work.
Related
I need to use the command line in Jupyter Notebook in a virtual environment, but the commands don't execute in the environment itself. I'm using Anaconda Navigator to open Jupyter Notebook. For background, I use a Mac.
Whenever I do something like ! pip install xyz, it installs the package in the Anaconda directory for libraries (see the image). I made sure that the kernel is in the environment, so that's not the problem.
What's interesting is that if I try to import a package, I can only import packages from the environment itself, not the Anaconda libraries. In other words, installing packages doesn't occur in the environment, but importing packages does.
Image that shows the pip install
This wouldn't matter that much because I could download packages in the Terminal itself, but I also need to do things like in the image below in my virtual environment, which is not possible to do in the Terminal (or is it?).
Example of what I need to do
Any ideas on how to fix this?
EDIT: That error is fixed. However, I'm getting an error if I try to use a Python command: image of error. The first line just defines the file path for the script (the last item in the list is a .py file). I tried doing "%%python" followed by the command, but it doesn't work. Any ideas?
I am having troubles trying to understand why VSCode uses a different pip version.
I have two python versions installed in Windows, python38 and python39, if I open the win 10 terminal I got pip version 20.2.4 when running pip3 --version, but if i run the same command inside the VSCode terminal i got pip 20.2.2 from c:\python38\lib\site-packages\pip (python 3.8).
Both terminals are running PowerShell 7.0.3 on the same profile.
Also removing python38 from the global PATH variable gives command not found error only in vscode, in windows terminal keeps working as i described before.
Could not fix this so I deleted all temporary and profile data of vscode and can now run pip from within its terminal.
Try changing your interpreter: ctrl+shift+p->select python interpreter and choose the one you want because pip is part of the python environment, and therefore the version of pip you are using is tied to the active python interpreter (cc #DragonBobZ)
It's all about the Process PATH. Check $Env:PATH in both. Starting from the left, the first folder with pip3.exe is used. You have probably selected a python interpreter for VS Code, which then adds it in the PATH.
You can also check the location of the used pip3.exe with Get-Command pip3. (might be helpful in debugging)
It appears something got fixed after deleting all profile and settings data from visual studio code, it runs pip now form the terminal inside vscode.
I just updated my macOS to Catalina and I can't run python or open a jupyter notebook from terminal anymore. As an example, I get error message "ImportError: No module named pandas" when running my python code, and I get
zsh: command not found: jupyter
when running
jupyter notebook
This issue has brought me to anaconda (I would love someone to explain me why. Does python need anaconda to be ran?). I have tried several suggestions from https://github.com/ContinuumIO/anaconda-issues/issues/10998, e.g. I have tried copying folder "anaconda3" from "Relocated items" folder to "Users//", then
export PATH=''/Users/<username>/anaconda3/bin:$PATH"
but I get either
dquote>
or
zsh: /Users//Applications/anaconda3/bin/conda: bad interpreter: /anaconda3/bin/python: no such file or directory
I then tried to reinstall Anaconda using the graphic installer (from https://www.anaconda.com/distribution/#macos) following advice from someone from the anaconda team (https://www.anaconda.com/how-to-restore-anaconda-after-macos-catalina-update/) (I changed installation location to a folder I created in /Users//) but I still get the same error messages when running python3 or jupyter notebook.
How can successfully run python and jupyter notebook with macOS Catalina?
After installed macOS Catalina, we can switch the terminal from bash to zsh. There are many advantages from using zsh instead of bash, but One of the issues with zsh is some of the frameworks (jupyter notebook,conda) are not supported directly. Once I typed jupyter notebook in terminal to run it. It displayed “zsh: no such file or directory”.
The solver is simple but very difficult to find online.
If jupyter was already installed before the update and stopped working after zsh, you should be able to fix it by:
1.open zshrc in terminal by typing: open .zshrc or $open .zschrc
2. add the following line at the end of the file:
source ~/.bash_profile
It will ask zsh to use all the information from bash like the path of jupyter.
Hope it can help you out!
I'm answering to my own question in case it can help others ;)
I found my answer here: https://medium.com/#singhaniatanay18/mac-os-catalina-update-zsh-instead-of-bash-d688f68f70b8
(see comments as well)
Mac OS BigSur:
Uninstall Anaconda:rm -f Anaconda-Navigator.app
re-install pip3 install jupyterlab
I just updated to Catalina, two days before Big Sur release.. oh well.
Catalina came with changes to security and bash, that will remain for future releases. So Catalina moves your anaconda3 folder to /Users/Shared/Previously Relocated Items/Security/anaconda3 I tried to move it back to home directory, but that didn't work. So I deleted it, and reinstalled Anaconda using the command line installer Not the GUI installer, and it worked for me. You can follow instructions here and use /Users/me/anaconda3 folder as recommended here.
Here are the commands that worked for me,
shasum -a 256 /Users/username/anaconda3 . Although not sure it did anything
bash ~/Downloads/Anaconda3-2020.02-MacOSX-x86_64.sh or whatever the name of the command line installer from Conda in your Download folder, or wherever else you downloaded it.
Use sudo in front of the command if permission was denied, then enter your log in password for your Mac
source /Users/username/anaconda3/bin/activate conda init zsh
sudo conda init zsh then enter your Mac's password.
You should be all set now, and all commands like ipython, conda info, jupyter notebook, pyspark will all work.
The last command will make step3 command persist i.e. initialize conda base environment, such that you can run conda, ipython, jupyter notebook the next time you use terminal.
Install the Jupyter using Homebrew in zsh shell
If you don't Python install 3.3or higher.
Open terminal
Using Homewbrew install jupyter
brew install jupyter
Now, you start a notebook
jupyter notebook
I am trying virtual env for the first time in python. I have Python 3.6 and Python 2.7 installed in my machine. I have installed all the necessary packages in Python 3.6. However, the code that I have seems to be compatible with Python 2.7. Hence I opted for Virtaul Env. But I could not access the packages that i need. I have went through the questions in stack overflow but nothing helped.
I have tried following steps:
Created new project in pycharm
used the interpreter as Python27
in command prompt, I went to specific virtual env folder and tried
pip install package_name
showing the error as below
Fatal Python error: Py_Initialize: unable to load the file system codec
File "D:\Users\username\venv_name\lib\encodings\__init__.py", line 123
raise CodecRegistryError,\
^
SyntaxError: invalid syntax
Current thread 0x0000d85c (most recent call first):
I need either to install packages in the venv or transfer already installed packages into venv.
Thanks
In order for you to install packages to your virtual environment you need to add it first in PyCharm and use it as your interpreter.
You can add your venv by:
By going to Settings(Ctrl+Alt+s in windows)
Click the ⚙ icon next to project interpreter then choose add.
Browser for your virtual environment.
After that you can now install packages to your virtual env by clicking the ➕ icon.
Also you cannot just install packages in your virtual environment by going to its directory, you need to activate it first by:
Windows: c:\path\to\your\venv\Scripts\activate.bat
Linux/Mac: source path/to/your/venv/bin/activate
I don't know how to solve your problem, since I don't use pycharm myself, but I can tell you what's causing it.
It seems that you are trying to run Python 2 code under Python 3. The raise expression that fails for you is valid under Python 2, but not under Python 3. Therefore the SyntaxError. So, you are probably using the source files from the virtualenv (see that ...\venv_name\... path?), but executing them in Python 3 interpreter.
From another SO post, the issue is PYTHONPATH. Clear it, and you should be able to use 2 and 3.
I have downloaded the new IntelPython and installed the package according to the directions on the page.
So, after I installed the application, I followed these instructions for Windows:
Open a terminal or shell and then navigate to the installation
folder. This will normally be C:\IntelPython3. Navigate to the
Scripts folder, and run activate.
After the script activates the
root Python environment, Intel Distribution for Python is ready to
use.
All good so far, then when I activated the root environment I started installing packages with pip, keras, tensorflow etc.
Amongst the packages I installed spyder too.
The issue is that when I am on the environment root I can type python and I start python 3.6 normally where then I can import all the packages that I installed.
But, when in the command window (while I am in the root env) I type spyder nothing happens. Instead I get a message that
Spyder is not recognised as an internal command
If I type, within C:\IntelPython3, conda list then I can see spyder but as I said the command doesn't work. I tried to find the spyder.exe within the C:\IntelPython3\Scripts folder but there is not there.
Any suggestions? Thanks
Edit: I can start Jupyter Notebook too from Windows terminal, the only issue is Spyder which is weird.