Octave not recognizing python is installed - python

I am trying to install the symbolic package in octave, I have the package in the correct directory, which is my current directory in Octave, but when it tries to install the package it gives me an error saying it can't find python. I'm using octave version 4.0.0 and just installed Python 2.7.10. Here is my code attempting the install:
>> pkg install symbolic-2.2.1.tar.gz
configure: error: Failed to find Python
checking for python... no
pkg: error running the configure script for symbolic.
error: called from 'configure_make' in file C:\Octave\Octave- 4.0.0\share\octave\4.0.0\m\pkg\private\configure_make.m near line 79, column 9
In case it is relevant, Python is installed outside of the octave directory. If there is an easier way to get symbolic capabilities in octave please let me know.

First open the prompt and run 'python'. If the python console is not opened and the prompt says that this command is not recognized, you have my same problem and I was able to fix just adding python to the environment path.
To fix it:
Hold Win and press Pause.
Click Advanced System Settings.
Click Environment Variables.
Append ;C:\python27 to the Path variable.
Restart Command Prompt.

Related

Install Matlab engine in Anaconda Python (Windows)

I'm trying to install the matlab.engine package for anaconda spyder on windows.
I have tried:
cd matlabroot\extern\engines\python
python setup.py install
But i get the error: could not create 'build'. Access denied. I've tried searching for answers, but I don't understand them.
Hope you can help :)
Try open terminal (cmd.exe) as admin. And more information about the process (if you are using anaconda prompt, cmd, powershell).
For this setup, I am using Windows 10, MATLAB R2020b and Pycharm.
Create new Condo environment in Pycharm (add Intepreter)
Sanity check that the python.exe exist within the newly create env
Add the C:\Users\author\Anaconda3\envs\integrate_matlabs in path. On the Windows Search Bar, type Edit the system environment variables Click the (1)Environment Variables.., (2) Path which is located under the section System variables, (3) Browse.. and browse to the C:\Users\author\Anaconda3\envs\integrate_matlabs.Finally click (4) OK.
Start MATLAB and type matlabroot in the command window. Copy the path returned by matlabroot.
'C:\Program Files\MATLAB\R2020b'
On search Bar, type Command prompt, right click, and select run as administrator
On the command prompt, type
6a) cd C:\Program Files\MATLAB\R2020b\extern\engines\python
6c C:\Program Files\MATLAB\R2020b\extern\engines\python>python setup.py install
A long list of log will be displayed. Wait until the line
C:\Program Files\MATLAB\R2020b\extern\engines\python>
which indicate the installation is complete.
Restart the MATLAB,
Type pyversion() on the Matlab command window which will displayed
If you have already built the matlab.engine package previously and just want to use it in another environemnt, just navigate to
matlabroot\extern\engines\python\build\lib
and copy the matlab folder into the Lib folder of your environment.

why doesn't it recognize the command and can't open the file when installing modules and packages with pip?

ON WINDOWS, when trying to install packages or modules for Python 3.7. Eg.
When using the "pip install beautifulsoup4" command on cmd it just says:
""pip" isn't recognized as an internal or external command, program or executable batch file."
or
pyhton.exe: can't open file 'pip': [Errno 2] no such file or directory
I use jupyter notebook and when ive been able to run any instalation instead of showing the complete and correct instalation always shows Warning messages saying about it working with TLS or SSL but the SSL is not installed or somethign like so.
I'm checking if the moduls are getting installed with a little code
try:
import numpy
except ImportError:
print("Module not installed")
aparently numpy it does is installed but others are not getting installed
When using the "try" code i hope not to get the message and be able to use the modules.
You probably didn't add Python to your Windows Path.
Here it is well explained how it works: (https://geek-university.com/python/add-python-to-the-windows-path/) :)
Yes. Even though python installed on Windows, it may be not pointing python path correctly.
Please ensure there is path for python in System environment.
Start -> type system environment -> Edit system environment -> System variables -> Path -> Please make sure you have path added for python -> Ok(Save).
And restart command prompt and run it again.
in command prompt,
py --version
or
python3 --version
This should be tell you the version of python
Also
pip --version
This should be work too.

Module not found error in VS code despite the fact that I installed it

I'm trying to debug some python code using VS code. I'm getting the following error about a module that I am sure is installed.
Exception has occurred: ModuleNotFoundError
No module named 'SimpleITK'
File "C:\Users\Mido\Desktop\ProstateX-project\src\01-preprocessing\03_resample_nifti.py", line 8, in <module>
import SimpleITK as sitk
I installed the module using
sudo pip install SimpleITK
I know that it was installed because I was getting a similar error when I ran the code through the command line, and it was fixed by doing the above. I don't understand why VS code does not recognize that
After installing a new module via pip reloading vscode may work if vscode doesn't recognize it. To do this, make sure that the module is installed inside the virtual environment by creating and activating a virtualenv:
python3 -m venv env
source env/bin/activate
Make sure to use the correct way of installing a module with pip:
python3 -m pip install {new_module}
Replace the string "{new_module}" with your module name. After that, make sure to reload vscode by clicking Ctrl+Shift+P, and selecting Reload window.
Now vscode will know the new module and autocompletion works.
sudo pip install is most likely installing globally into a Python interpreter that is different than the one that you have selected in VS Code. Please select the Python interpreter you want to use and then install explicitly using that interpreter (if you're not using a virtual environment then use something like /path/to/python -m pip install SimpleITK, although I strongly recommend using a virtual environment and to not install packages globally).
In Mac, correctly selecting the Python Interpreter worked for me:
From within VS Code, select a Python 3 interpreter by opening the Command Palette (⇧⌘P), start typing the Python: Select Interpreter command to search, then select the command. You can also use the Select Python Environment option on the Status Bar if available (it may already show a selected interpreter, too):
No interpreter selected
The command presents a list of available interpreters that VS Code can find automatically, including virtual environments. If you don't see the desired interpreter, see Configuring Python environments.
Source :VS Code Select Interpreter
This error: your vscode use other python version. This solution change vscode use current python.
In terminal find current python version:
py --version
In vscode Press Ctrl+Shift+P then type:
Python: Select Interpreter
Select current python version
I ran into this problem with VSCode and resolved it by setting my Python interpreter within VSCode to the same as the one in my system path (type "echo %PATH%" on Windows and look for Python) via the process here: https://code.visualstudio.com/docs/python/python-tutorial#_select-a-python-interpreter
There are a lot of proposed answers that suggest changing the launch.json or the settings.json file. However, neither of these solutions worked for me.
My situation:
Is Python environment selected? yes
Does the Terminal recognize Python environment? yes
Can I run the Python code from the activated Terminal? yes
Does the code run w/o error when I use "Start Debugging"? yes
Does the code run when I click "Run Code"? no
The only solution that worked for me is to:
Open Windows Terminal (or cmd)
Activate environment: conda activate <environment_name>
Open Visual Studio Code from Terminal: code
Then, "Run Code" (#5) works without any issues.
Source:
"module not found error" in VS Code using Conda - l3d00m's answer
Faced similar issue and here is how I fixed it. Remember that there are multiple ways to run your code in VS code. And for each way you may end up with different interpreters and environments. For example:
1. Creating virtual env and installing libraries
In my case I opted into creating virtual environment and doing so outside of VS Code using command prompt:
python -m venv .plotting_test
Following that I activated it:
.plotting_test\Scripts\activate.bat
Following that I installed additional libraries:
python -m pip install matplotlib
Following that I made sure to see it was all installed ok:
python -m pip list
And I also checked where for current directory:
cd
2. Point VS Code & VS Code Code Runner to virtual environment
Opened vs code, closed previous workspaces, opened new folder, created test.py as I was starting new. Pressed ctrl + shift + p. Selected ```Python: Select Interpreter``:
Followed by + Enter interpreted path
Navigated to directory from last step from section 1. Found my virtual environment folder created in step one and pointed VS code to that version's python.exe in Scripts:
Verified I am pointed to such:
Saved as workspace so that I can create default workspace settings for this project:
In workspace settings files defined paths to my virtual environment created n step 1 for workspace interpreter & CODE RUNNER(!):
"settings": {
"python.defaultInterpreterPath": "C:/Users/yyguy/.plotting_test/Scripts/python.exe",
"code-runner.executorMap": {"python": "call C:/Users/yyguy/.plotting_test/Scripts/activate.bat && python -u"}
}
}
Reloaded window just to make sure (ctrl + shift + p) = "Developer: Reload Window"
Now run code and run python file should be execute under your specified envs:
Try running pip list in VS Code to check if the module is installed, next check if your python version is correct/supports that version of SimpleITK. It may be a problem with the python interpreter that you are using for VS Code (ie. the module may be installed on a different python instance than the one your VS Code is using)
Is Python environment selected?
Does the Terminal recognize the Python environment?
Can I run the Python code from the activated Terminal?
Does the code run w/o error when I use "Start Debugging"?
if the answer to the above is "yes."
Then,
Try running the Code using the option "Run python file in terminal" (in code runner extension). And assign a new shortcut for that for future use...
How to fix module not found error in Visual Studio code?
To Solve VSCode ModuleNotFoundError: No module named X Error Make sure you are running from the package folder (not from package/module ) if you want import module. calculations to work. You can also set the PYTHONPATH environment variable to the path to the package folder.
Once you have created a virtual environment, and installed your required packages in that environment, close VS code. For Windows platform, open command prompt and navigate to the folder where your virtual env folder is created. And then launch VS code from there using the command code .
For ex: My virtual env name is .imgenv, and its inside C:\py_stuff\projects
So, I navigate to C:\py_stuff\projects and then type code .
Now, your VS code should recognize the packages !
I just ran into the same issue. I found that if I selected all text before shift enter the script would compile as a file instead of as a single line.
I had the same problem. I bet you have a shebang statement at the top of your file.
If you do.
Visual Studios settings
Under "Code-runner->Code-runner: Respect Shebang" section or just do a search for "Code-runner: Respect Shebang"
Uncheck weather to respect Shebang to run code.
Now it will run under the virtual environment and find the modules that you installed using pip! :)
I struggled with this for a very long time, and had tried almost every other answer. I wasn't using pip, so that wasn't the issue. But still VS Code wasn't finding the modules that were installed in the Selected Interpreter.
Ultimately it came down to old conflicts that existed because I switched to miniconda, and VS Code was still looking for anaconda3.
I completely wiped VS Code and its associated files (cache, preference files, etc.) from my machine (some instructions), and installed a clean version.
This now syncs as expected with miniconda.
If you have different python versions installed, be sure you install module with right one.
python -m pip install <module>
or
python3 -m pip install <module>
Run your environment from a directory not in the users directory. I solved my problem running my environment from C:\Code\ProjectA\
I discovered my problem by running:
IMPORT os
Mycwd = os.getcwd()
PRINT(Mycwd)
.venv/Lib/SitePackages is the default directory where Vscode looks for Modules.
This directory is automatically created on creating .venv via the command Pallete.
External modules installed via pip are placed in this directory by default.
Place self created modules inside this folder manually.
For mac users
In the terminal check which python you are using by command which python. It will give you the path of the python interpreter path. After that type cmd shift P and type Python: Select interpreter.
After that select + Enter interpreter path and paste the path which you got after running the command which python.

Python_d.exe and venv -- can't find "python_d.exe"

I'm using PyCharm and trying to set up a Flask project with a virtual environment. Whenever I select to do "New environment using Virtualenv" the base interpreter location seems to be right yet I continually get the error that there is no such file or directory "\python_d.exe" I don't think this is just a PyCharm error as I also get the same error when trying to do it from the terminal. I'm not quite sure why it's looking for python_d.exe instead of python.exe
I've already edited my PATH variable to be where my python executable is stored. And while installing Python (at the recommendation of other questions on this forum), selected to add to the PATH variable and also install for all users. I'm not sure where else to go on this, so any help is appreciated.
This is the error I get when I run the below command on the terminal.
> python -m venv C:\<path to where I want it to go>\venv
Error: [Errno 2] No such file or directory: 'C:\\<my specific path>\Python\\Python37-32\\lib\\venv\\scripts\\nt\\python_d.exe'
In the installation program of python seek if you have installed the debug file binaries.
python_d.exe is a file installed with that option activated.

Compiling python project

this is my first time on posting a thread on stackoverflow, but I have used this many times in the past. I am having a problem when compiling my python files. I have looked many times on here and on other sites on how to do this and I keep getting the same answers. For some reason, on my computer, I cannot run/install pip. Whenever I try to install pip by using the python command, it is not recognized. I saw a thread on here about using 'py' instead of 'python', this is accepted as a command but when I try to install pip it just errors. I have installed python several times and have also repaired it several times, but nothing seems to work.
Any help would be greatly appreciated!
Welcome to stackoverflow!
this is an image i took from a website if you would like to use PIP
the website: https://packaging.python.org/tutorials/installing-packages/#ensure-you-can-run-pip-from-the-command-line
I took a look at the directory that you specified in your comment. Pip is not an executable file there, but rather is python source code. What I found that worked and allowed me to run Pip successfully was to import Pip as a module within the system Python environment. Then run Python specifying Pip as a loaded module using the -m flag to call pip as an executable with its own arguments (e.g. C:\Users>python -m pip --version). The steps to set this up are included below:
Step 1: Verify that Python is installed and is added to your PATH variable
From cmd, run the command: C:\Users> where python. You should be returned a file path to the executable for Python.
If instead you receive an error message that says the following: "INFO: Could not find files for the given pattern(s)." that means that Python is not added to your $PATH variable (See below for details on how to configure your PATH variable.
Step 2: Add Pip source code as a module within Python
Run python from the cmd: C:\Users> python
Run the command import pip within the python shell:
Run the command exit() to return to the cmd from the Python shell.
Step 3: Validate that pip can be used as a module within Python
Run the following command to check Pip's version as a validation that Pip and Python are configured correctly: C:\Users> python -m pip --version
Validate that you are returned a version number
Configuring PATH environment variable (Windows 10)
From the start menu search box, type "edit the system environment variables".
Open the application that is returned (should pop open the control panel).
Click the button entitled 'Environment Variables'
If you have a variable defined as 'PATH' already, click the edit button, then click 'new' in the following dialog box. Specify the path to your Python executable ( C:\Users\jakes\AppData\Local\Programs\Python\Python37-32\Lib\site-packages). Click 'Ok' and then 'Apply.'
If you don't already have a 'PATH' variable defined, click 'new' and define a name of 'PATH' and add in the file path to the Python executable as the variable's value.
Close any active Command Prompts! After making changes to your PATH variable,you will need to close any active sessions in order to allow the update PATH variable to be propagated within the session.
Open a new Command Prompt window and run the command: C:\Users> where python to verify that the your changes were made correctly, and that they have fully propagated within the system.

Categories