Anaconda -- conda create results in "Failed to create process" - windows-10

I recently installed Anaconda onto my laptop and I am trying to install a conda environment called pydecal that uses python 3.5. I have tried this in CMD as well as in Anaconda Prompt. I did not enter Python when Below is my code:
conda create --name pydecal python=3.5
I am getting a "Failed to create process." message every time I try to run the command. Anaconda installed fine in 64-bit. I am on a clean install of Windows 10. I have no other instances of Python on my computer whatsoever. I have tried running CMD and Anaconda Prompt as an administrator. I have restarted my laptop several times. Regardless, I run into the same problem. Any ideas on what is going wrong?

Did you install it on the primary drive (C:)?
My conda did not work either. I have just uninstalled Anaconda3 which was formerly installed in a secondary drive (E: rather than C:).
After installing Anaconda3 on the primary drive (C:), conda seems to work fine.

I solved it by making this way:
1: Install Anaconda in a directory structure not containing spaces.
2: Modify system environments to not include %PATH% in the user section.
I found that 'echo %PATH%' in a prompt resulted in the system defined paths, were shown twice.
3: Moved all paths containing %SYSTEMROOT% to the top search order. This was to assure the need to search obscure named paths was not searched by the 'activate' command.
Let me know if this solves your problem.
Br Michael

I solved it this way:
Opening the "Anaconda Prompt" Console Link that Anaconda creates in the start menu. As conda appeared to work fine there I copied the predefined envinronment variables for that prompt :
If you check the link, it executes this:
%windir%\System32\cmd.exe "/K" C:\tools\Anaconda3\Scripts\activate.bat C:\tools\Anaconda3
and that file refers to C:\tools\Anaconda3\condabin\conda.bat
So finally the path is specified there as :
C:\tools\Anaconda3;C:\tools\Anaconda3\Library\mingw-w64\bin;C:\tools\Anaconda3\Library\usr\bin;C:\tools\Anaconda3\Library\bin;C:\tools\Anaconda3\Scripts;C:\tools\Anaconda3\bin;C:\tools\Anaconda3\condabin;
I added that to the Windows System Environment variables and it now works properly on git bash, and other shells.

pip install pathlib
that is what i did now everything works

Related

How to resolve 'Import "django.contrib" could not be resolved from source' in VS Code?

This error suddenly came up when I created a new Django project. I used pip to install all the packages in the virtual environment.
I had exactly the same problem and there are several solutions out there, but only #Neha's answer has brought me to the point. The problem here is really simple. VS Code uses your "main" Python interpreter, whereas you should use the one in your virtual environment for Django.
In other words, I have my main Python installation here:
c:\users\yourName\appdata\local\programs\python\python39.
And my VS Code has pointed to exactly this interpreter. But my Django was installed in this path:
c:\users\yourName\source\vscode-repos\basic-app\backend-service\venvs\lib\site-packages.
In order to solve it click on the
VS Code bar with Python Interpreter, you will then see a pop-up window. Choose + Enter interpreter path... then Find.... It will open File Explorer for you. Go to your virtual environment folder, where you have your Django installed (in my case it the vscode-repos\basic-app\backend-service\venvs folder), inside of it go to the Scripts folder and pick python.exe, like this. And you are good to go!
Actually all of the answers were right , but what worked for me is:
Type pip show Django in vsc terminal
Go to the path of intallation mentioned there
It will be inside "lib" by default..go back to scripts
Inside the scripts , there will be python .exe app
Choose this as your interpreter (as per above answers)
Select the Python interpreter in which you have created the virtual environment. I had the same error and this solution worked.
Below is a screenshot that you can refer to.
If you are using VScode, click the python version on the bottom left corner and select the venv where you have installed the packages.
For anyone who can't see the virtual environment then click on the python version below right corner of vscode,click on Enter Interpretor Path,click find,chose the folder that you are working,click on virtual environment name ,then click bin and select python version and the warning will be gone.
In my case (on MacOS) the problem was caused by creating venv using default arguments.
I don't have Scripts directory, but I've got bin inside. The python3 -m venv my_venv command was creating symlinks to python and python3 executables which was confusing for the VSCode. After removing and creating again the venv with below command everything started to work
python3 -m venv --upgrade-deps --copies my_venv
Go to the Python(Extentions) below your screen Like this then select interpreter tab will pop up, then select C:\Python39\python.exe Like this.Hope it helps
What worked for me was to install django within my virtualenv. All other settings were correct in Visual Studio Code.

Starting with anaconda on Ubuntu 18.04

I installed latest version of Anaconda3-2020-02.
I was trying to follow this instruction in order to create environment for running with python==3.6 instead of python==3.7., because I have python 3.6. installed.
So, running the
conda create --name snakes python=3.6
and then activating my environment with conda activate snakes, it enters environment (snakes). However there are no anaconda packages inside like jupyter notebook or others, no anaconda-navigator... So whats the purpose of it and how can I run these programs from environment?
Also, for some reason (when I am not in the environment, just regular bash shell) $PATH is not set up to the /bin directory in anaconda, just to /condabin. Can you explain this also, because I am not able to run nothing except conda command from shell after recommended installation.
If by default after installation environment is not activated, you should activate it by sourcing a file anaconda3/bin/activate. You will see indicator (base) on the left of your bash prompt.
Good thing about anaconda3-2020-02 is that it is not messing with system python, as newest python is being launched inside environment and proper$PATH is set up just inside environment. If only, for some reason, specific version of python is needed, then it makes sense to set it up with this instruction. I would be just using default one with python 3.7 probably from (base) environment.
Keep in mind that by default anaconda components are not being set up inside new environment being created. In order to bring them, for example jupyter, you should run the command like this:
conda create --name snakes python=3.6 jupyter

Pip freeze doesnt show freshly installed packages with Pycharm

I use Pycharm to create and manage my virtualenvs in my projects.
The problem is that after adding a library with pycharm, when I type the command (pip3 freeze --user), the library does not appear in the command result.
I have to manually type the pip install command each time so that the library is visible.
What manipulation should I do in PyCharm to solve this problem?
For what you are saying, the first thing that comes to mind is that you should use:
pip freeze
And not
pip3 freeze
Because the command mapped to the pip version when you have virtualenv activated is the first. Note that for installing you seem to use pip, and not pip3
Moreover, the --user option afaik is related to the packages installed in the user folder:
--user Install to the Python user install directory for your platform. Typically
~/.local/, or %APPDATA%\Python on
Windows. (See the Python documentation for site.USER_BASE for full details.)
If your packages are installed in the virtualenv folder, I would tell you to not use that option.
Also please make sure you have your virtualenv activated. In linux you can do so by source path/to/virtualenv/activate
Edit
I understand that the reason you are using pip3 is because you may have different versions of Python in your machine. Let me explain you a bit further how it works, because version management is usually a headache for many programmers and it is common to find problems when doing so.
If you install different versions of Python in your linux machine, and you do that as root, then the installation will proceed for the whole system. Usually Python2 installation folder for Linux machines is /usr/bin/python. However, I am uncertain of which directory is used for Python3 installations. You can check that easily by doing whereis python3. You can serach the path to binary of any command by doing whereis command. Note that this works also for whereis python as far as you don't have virtualenv activated.
Aditionally, the link to the binary of a command (or the set of instructions to be exectued, more broadly) is defined in certain folders in Linux, depending on whether you created the command as root or as a user, and possibly also on the distro. This works differently in Windows, that uses the Registry Edit utility to handle command mappings. When you enable your virtualenv, what you are doing is creating an environment that enables mapping system commands such as python to the Python installation in your virtualenv folder.
When you disable the virtualenv, the command points again to the default installation path. Same happens with pip, so incorrect usage of this tool may result in different packages being installed in different locations, and therefore not appearing available for the right Python version at any given circumstance.
In Linux, environment variables are shell dependent, though you can write them out with echo $variable and set them with variable=value (from bash). The search path is simply called PATH and you can get yours by typing echo $PATH.
Source: https://askubuntu.com/a/262073/426469
I encourage you to check other questions in SE network such as this: https://unix.stackexchange.com/a/42211/96121, to learn more about this.
Addendum
Quick tip: it is common to use the pip freeze command as follows:
pip freeze > requirements.txt
It is a standard that leads to understanding that modules in such file are required for the correct functioning of your application. That lets you easily exclude the virtualenv folder when you install the program in another computer, since you can readily know the requriments for a fresh installation. However, you can use the command as you want.

I don't understand the error I get while activating environment in Anaconda

I reinstalled Miniconda (version 4.3.21) at c:\Miniconda3, created an environment named data and also installed some packages in this environment. The Python version came with this Conda is 3.6. However, before installing the Miniconda, version 3.4 of Python was already installed on my system (location c:\python34). OS is Windows 7 (32 bits).
On command line, I can run command like conda info --envs or conda create -n data. I can even open Python IDLE by running idle command which opens the IDLE for Python which came wih Miniconda. But when I try to run activate data, it shows this error.
However, when I run command line as administrator, I am able to activate environment. If I remember correctly, earlier I was able run all commands without needing any admin privileges. Why does this happen?
So what is happening is that your user likely has the original Python executable(or old Miniconda Python) in your users PATH and this is found before Minconda Python. When run as Admin(because installing to C:\Miniconda requires admin privileges) it finds the correct executable that is in the System PATH. Having both a standard Python and Miniconda in your user Path will cause issues as it will use the first Python.exe found based on your PATH.
Check Computer > Properties > Advanced System Settings > Environment Variables.
Put Minconda before the standard Python or remove the standard python(there is no difference between standard python and the python included with Miniconda as they both come from python.org). You may also need to set the permissions on the entire C:\Miniconda directory for your user. Even though you have admin access you will still need to escalate privileges if you don't set permissions for your actual user.

'python3' is not recognized as an internal or external command, operable program or batch file

I am using Python 3.5.2 version on Windows 7 and tried using python3 app.py. I am getting this error message:
'python3' is not recognized as an internal or external command,
operable program or batch file.
Is there any specific cause about why the python3 command is not working?
I also verified that the PATH is added to environment variables.
There is no python3.exe file, that is why it fails.
Try:
py
instead.
py is just a launcher for python.exe. If you have more than one python versions installed on your machine (2.x, 3.x) you can specify what version of python to launch by
py -2 or
py -3
You can also try this:
Go to the path where Python is installed in your system. For me it was something like C:\Users\\Local Settings\Application Data\Programs\Python\Python37
In this folder, you'll find a python executable. Just create a duplicate and rename it to python3. Works every time.
Python3.exe is not defined in windows
Specify the path for required version of python when you need to used it by creating virtual environment for your project
Python 3
virtualenv --python=C:\PATH_TO_PYTHON\python.exe environment
Python2
virtualenv --python=C:\PATH_TO_PYTHON\python.exe environment
then activate the environment using
.\environment\Scripts\activate.ps1
Yes, I think for Windows users you need to change all the python3 calls to python to solve your original error. This change will run the Python version set in your current environment. If you need to keep this call as it is (aka python3) because you are working in cross-platform or for any other reason, then a work around is to create a soft link. To create it, go to the folder that contains the Python executable and create the link. For example, this worked in my case in Windows 10 using mklink:
cd C:\Python3
mklink python3.exe python.exe
Use a (soft) symbolic link in Linux:
cd /usr/bin/python3
ln -s python.exe python3.exe
In my case I have a git hook on commit, specified by admin. So it was not very convenient for me to change the script (with python3 calls).
And the simplest workaround was just to copy python.exe to python3.exe.
Now I could launch both python and python3.
If python2 is not installed on your computer, you can try with just python instead of python3
For Python 27
virtualenv -p C:\Python27\python.exe django_concurrent_env
For Pyton36
virtualenv -p C:\Python36\python.exe django_concurrent_env
Enter the command to start up the server in that directory:
py -3.7 -m http.server
I had a related issue after installing windows 11, where python3 in cmd would open the windows store. I was able to sort it out between this post and this other one. In short, I reinstalled python and made sure to add it to PATH. Then, in settings, Apps > Apps & Features > App Execution aliases. Here, all I had to do was make sure that every single python .exe (including idle and pip) were turned off EXCEPT FOR the python3.exe alias. Now it works like a charm.
FWIW:
The root of this issue is not with you or with python. Apparently, Microsoft wanted to make installing python easier for young kiddos getting interested in coding, so they automatically add an executable to PATH. For those of us that already have this executable, it can cause these issues.
Found out instead press the play button the top right and it should work in visual studios:
Do not disable according to first answer
Saying python3 in the command will not work by default.
After figuring out the problem with the modules (Solution): https://youtu.be/paRXeLurjE4
Summary:
To import python modules in case of problem to import modules:
Hover over python in search:
Click open in folder
Hover over and right click
click properties
copy everything in path before \python.exe
close those windows
For cmd (administrator):
cd --path that was copied--
then python -m pip install --upgrade pip
cd Scripts
pip install "Name of Package" such as pip install --module (package) --
Im on win10 and have 3.7, 3.8 and 3.10 installed.
For me "python" launches version 3.10 and does not accept commands (like -3.7), "py" launches newest version but does accept commands, and "python3" does nothing.
Uninstalled 3.10 and "python" now does nothing, and "py" launches 3.8.
I am unable to add a comment, but the mlink option presented in this answer above https://stackoverflow.com/a/55229666/8441472 by #Stanislav preserves cross-platform shebangs at the top of scripts (#!/usr/bin/env python3) and launches the right python.
(Even if you install python from python.org, Windows will direct you to the app marketplace nowadays if you type python3 on the command line. If you type python on the same cli it will launch the python.org version repl. It leads to scripts that generate no output, but more likely silently failed completely. I don't know ho common this is but have experienced it on a couple of different devices)
If you have this at the top of your script to ensure you launch python3 and don't feel like editing everything you own, it is not a bad approach at all... lol.

Resources