How to start using `scipy` - python

I have previously installed Python 3.4.2 and 3.5.2 and in both cases I can dabble in writing and testing code in Idle which gives me two windows -- a "Run" window for code, and a "Shell" window for interaction and output (sorry, not sure of the correct terminology).
Now I'd like to try out scipy, particularly scipy.spatial.
First, I downloaded WinPython (WinPython-64bit-3.4.3.6Qt5.exe) from sourceforge.net/projects/winpython/files/ but when I tried to install it, it wanted to put it in my Downloads folder (where the installer was saved, obviously) so I browsed to Program Files and tried to install there but I get
Error opening file for writing
C:\Program Files\WinPython-64bit-3.4.3\IDLE (Python GUI).exe
Same response at C:\Program Files (x86)\.
Next, I downloaded just scipy-0.16.1-win32-superpack-python3.4.exe and it seemed to be successfully installed until I try to run import scipy in my usual "Run" window I get
ImportError: No module named 'numpy'.
Third, I retried WinPython-64bit-3.4.3.6Qt5.exe again, but this time accepting the default Downloads install location. This time there was a successful installation of python-3.5.1.exe in Downloads. When I ran it I chose "Repair" and eventually got "Repair was sucessful." However, when I try to run import scipy in my usual "Run" window I get
ImportError: No module named 'scipy'.
What steps am I missing? What is the easiest way for me to try using scipy?

Assuming you have correctly installed Python, you can try using the .whl (wheel) files available on the LFD's website.
First, make sure you have an updated version of pip which supports the use of .whl files by using the following command in the terminal:
python -m pip install -U pip
Then, download the latest versions of the .whl files for NumPy and SciPy into some directory you can easily locate.
Afterwards, use the following command to install the .whl files you've downloaded in the necessary order:
python -m pip install C:/path/name-of-file.whl

Related

Issue to installing module in Thonny (Python text editor)

I downloaded Thonny (which is a text editor for python) for using my Raspberry Pi Pico, and I tried to install a module in "Manage packages", when I began the installation, this error line code appeared:
ERROR: Can not combine '--user' and '--target'
Process returned with code 1
Fortunately there is another way to install modules and I tried it:
Install from a local file: I installed the package in cmd pip install Adafruit-SSD1306 in target directory of the Thonny's modules C:\Users\33631\AppData\Roaming\Python\Python310\site-packages, but I still don't see the module I installed.
After that, I figured out I can't install modules at all, and it brings me the same error message.
I use:
Python version: 3.10
Pip version: 22.3
Thonny version: 4.0.1
I tried many things, change the directory, install with the cmd and research with the Install from a local file, but it is still not working.
I use also the Thonny editor several years, but have never used his Tool | Manage packages... function. I use always pip install ... instead.
If you open this dialog, it shows you a Target path something like C:\Users\your_user\AppData\Roaming\Python\Python311\site-packages, depending on your phython version and path. I assume that python packages are installed always under the phython directory like C:\Python311\Lib\site-packages. My Thonny editor is olso there. Have you searched into python site-packages directory, too?

Installing and using npTDMS with Spyder - anaconda3

I have successfully installed npTDMS as seen here:
https://pypi.org/project/npTDMS/
If I try to install with command line using either pip or conda I get a message confirming it is already installed, and I see the package at D:\Users\username\anaconda3\pkgs.
On Spyder I have tried using the PYTHON path manager (in the tools menu) to add both:
D:\Users\username\anaconda3\pkgs\nptdms-1.2.0-pyhd8ed1ab_0
D:\Users\username\anaconda3\pkgs\nptdms-1.2.0-pyhd8ed1ab_0\site-packages\nptdms
As far as I understand this should be enough to use the npTDMS package, however when I try to import I get a ModuleNotFoundError: No module named 'nptdms'.
I'm fairly new to python overall so maybe there is a simple thing I am missing.
This issue comes when there are multiple versions of python or any package you are running at current time. The same issue was with me too when the IDLE was not able to detect the position of where the package is installed.
My suggestion is that uninstall all the versions of python and the module you are using and install them again. Otherwise shift to any other IDLE, in my recommendation - Visual Studio Code.

Python : couldn't install py2exe using Winpython : not compatible error

I tried installing py2exe for converting python code to a exe file using WinPython-64bit-2.7.9.4.
I downloaded the file py2exe-0.6.9.win64-py2.7.amd64.exe
from https://sourceforge.net/projects/py2exe/files/py2exe/0.6.9/
While installing using WinPython Control Panel, it shows an error message as below.
rename it as py2exe-0.6.9.win-amd64.exe, then try again
Sometimes it doesn't matter what the file is called, WinPython control panel won't like it. In this case, open up "WinPython Command Prompt.exe" (which is in the same directory as WinPython Control Panel) and run:
python -m pip install "name-of-python-package.whl"
Note: pip also requires the package filename to be formatted correctly, but if you have the latest version of pip and the latest python package, you should be fine.
This question is also related: .whl is not a valid wheel filename, storing debug log for failure in C:\

Error installing from GitHub using pip on Windows

I am on a Windows machine and I want to install a Python module from GitHub using pip directly from IPython.
The simplest command that seems it should work is:
!pip install https://github.com/japerk/nltk-trainer.git
I have also tried:
!pip install https://github.com/japerk/nltk-trainer.git#egg=nltk-trainer
I've used variants including -vvv, etc.
However, I'm getting the following error. Why?
Cannot determine archive format of C:\Users\timo\AppData\Local\Temp\pip-build-183bwemw\nltk-trainer
go to the https://github.com/japerk/nltk-trainer and download the project zip file. extract the zip file and put it somewhere in your computer.
open command prompt in windows and go inside the folder that you extracted earlier(you must be in the folder that has setup.py file in it).
enter the following command: python setup.py install
python tries to install nltk-trainer . during installation some other dependency might be installed too. you need numpy and scipy to be installed. if any problem happened during installation of numpy or scipy try installing them manually first by using pip install numpy and pip install scipy
if you can't install numpy and scipy using pip command use the following link:
http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy
this site has compiled version of these libraries ( and other libraries if you need to install them too) you can download .whl file that is based on your python version and os architecture and install them using pip install filename.whl command ( you need to be in the folder that your whl file is) for example for python3.4 and 64bit operating system you may download scipy‑0.16.0‑cp34‑none‑win_amd64.whl file.

How can I install a .egg Python package on Windows (attempt using easy_install not working)

I am trying to install a package named QSTK for a course that I am doing. The course points to an installation package for the 32 bit version, but I have 64 Python installed. I have found a .egg file listed on the Python packages index.
It seems to have an exe for 32 bit, but just the .egg for 64 bit. I downloaded the QSTK-0.2.6-py2.7.egg version and have been trying to install this unsucessfully so far.
Here is what I have tried:
Using easy install (from the C:\Python27\Lib\site-packages
directory):
Python easy_install -Z C:\Users\Prosserc\Downloads\QSTK-0.2.6-py2.7.egg
this has created a QSTK-0.2.6-py2.7.egg directory in my
site-packages directory which I can open and find files in. However,
I have tried to import QSTK from the python shell and get the usual
"No module named..." import error.
I looked for a setup.py file as I have used these to install
packages before, but could not find one.
I have also looked at this thread which gives details of
installing a .egg file without using easy install, but cannot figure
out what changes I would need to make to the script provided as this
is to install a specific package that I already have.
If anyone can help by explaining either how I can install this .egg file correctly or by providing a link to the QSTK modules for python 2.7 64 bit in another format this would be greatly appreciated.
I have managed to install the packages that QSTK is dependant on okay (numpy, scipy, matplotlib, pandas, python-dateutil and scikit-learn).
You should add -m before easy_install
for example:
python -m easy_install C:\Users\Prosserc\Downloads\QSTK-0.2.6-py2.7.egg
How about if you unpack the .egg (it's just a .zip in disguise), then cd into it and run python setup.py install? Will that run fine and will you then be able to import your module?
I'm saying this because if the .egg file does get put under site-packages as appropriate but you're still not able to import, this might be a problem in the code itself.
I have finally found another place to download this from with a package that works: https://pypi.python.org/pypi/QSTK/0.2.6 has a QSTK-0.2.6.tar.gz option to build it from the source code.
Unzipping this (then again once down to the .tar), I could find the setup.py file and install by going to the directory with the setup file and running:
python setup.py install
I tried copying the contents of the .egg folder in the path Lib\site-packages .
It worked and didn't throw any ModuleNotFoundError .
I found pip install qstk works perfectly for 64x 2.7 python at win 7

Categories

Resources