Why isn't UniCurses for Python working? - python

I'm trying to make my first UniCurses project with Python on OpenSUSE.
I put the import statement in my .py file, but when I tried to run it, it says the module is not there... So I downloaded UniCurses from the website, and the instructions say Unix's Python already has UniCurses. That's odd, but I continued. I put the downloaded unicurses.py into my project directory, and when I tried running my file, an error message says UniCurses is not compatible with my system, and that either my Python distribution is below v2.6 or my operating system is something other than Windows or a *nix. My Python is v2.7.8, and again, my OS is a Linux distro. Why is this happening, and what should I do?
Edit: It's worth noting that the regular curses supposedly doesn't work on my system either.

Answer by Sagar Rakshe from How to install Python package from GitHub:
To install Python package from github, you need to clone that repository.
git clone https://github.com/jkbr/httpie.git
Then just run the setup.py file from that directory,
sudo python setup.py install
If you have already downloaded the file you can skip the first step and just run the python setup.py install in the folder. (I don't think sudo is necessary for python)

Related

I can't use pip (Windows)

I'm wanting to learn machine learning, but it requires that I use 'pip.' I'm still very new to a lot of this stuff. I've installed Python 3.4 64-bit and get-py.py.
When I run pip install sklearn I get 'pip' is not recognized as an internal or external command, operable program or batch file.
Here's a screenshot of my environmental variable PATH
https://gyazo.com/c7ec926401878845d5c4f9a556cf00ee
Any help would be greatly appreciated. I have checked out other posts where people had similar issues, but I tried various things and nothing worked.
Easiest solution is to just download a platform like Anaconda for example. It is Python with many libraries (sklearn, pandas, numpy, ...) and also with pip, all in a user-friendly Windows installer package, that takes care of everything for you.
https://www.continuum.io/downloads
If you really want to do it yourself, then
download get-pip.py (https://bootstrap.pypa.io/get-pip.py)
make sure you have Python installed and in your PATH, for example by running python --version in command prompt
Navigate to the directory, where you downloaded get-pip.py (in command prompt using the command cd).
Run the command python get-pip.py from a command prompt with admin privileges (possibly not needed, but just to make sure).
This should be all. Close your command prompt, open it again and run pip --version to test it. If it doesn't work, then search your computer for a file named pip.exe (most likely in your Python directory) and if you find it, add its path to your PATH variable (given the screenshot, I assume you know how to do this).
I downloaded Python 3.6 and the pip was installed on my system.
I found pip at below location:
C:\Users\Admin\AppData\Local\Programs\Python\Python36\Scripts
Also, before I found pip I used below command on my command prompt to install pyperclip:
python -m pip install pyperclip
For anyone that might have installed Python using the MSI installer, and ticked the box to include pip, but still gets the error 'pip' is not recognized as an internal or external command, operable program or batch file:
It looks like that the pip executable is installed in the \Scripts subdirectory of the Python installation, but that directory does not get automatically added to PATH.
For me, since I had installed Python 2.7, the directory was C:\Python27\Scripts. After adding this path to the PATH environment variable, and open a new CMD window, pip was available as a command.
I've made a workaround that will help you, copy the batch script below and modify it as specified:
#"PATH to python.exe" "PATH to pip.exe" %*
For example like this:
#"C:\programming\bin\python374\python.exe" "C:\programming\bin\python374\Scripts\pip.exe" %*
Save this file as pip.bat on Desktop and then move it to C:\Windows\system32.
For Python 3.7 or higher at least (as today is October 4th 2019) in the installation window you need to check the box "add to PATH" when you first install Python.
I'm late now, but just add python to your environment variables.
It´s explained in this short video, how to set up python to your environment variables:
https://www.youtube.com/watch?v=Y2q_b4ugPWk
after that pip should work on your cmd prompt, without cd to
"C:\Users\Admin\AppData\Local\Programs\Python\Python36\Scripts"
This is late but in case anyone runs across this issue, pip installed for me as "pip3". Once I used pip3 as my command and not pip, it worked fine. Threw me for quite a loop since I've been using Python for years.
PIP Install and Upgrade
Ensure you are accessing the right location while accessing pip as shown in my link above. Starting Python 3.4, it is included by default with the Python binary installers.
Environment Variable
It is also a good idea to update the environment variable if the path is not accessible by default, once the installation is complete.
If it is specifically pip you want you could install python again making sure to tick the install pip box which it sounds like you failed to upon initial installation.

Matplotlab .exe file for Python 3.4 cannot find path to Python34

I am running Windows and am a beginner python user trying to install a few modules to run a python script. I have Python 2.7.9 and 3.4.2 both installed to the C:\ directory. I downloaded matplotlib-1.4.3.win-amd64-py3.4.exe and the corresponding .exe for python 2.7 from the Matplotlib website, but when I run the py3.4 exe the program cannot find Python 3.4 to update (Cannot install: Python version 3.4 is required, which is not found in the registry).
Python 2.7 installer works perfectly. Is there a misset PATH variable in Windows I can modify so the .exe can function properly? In CMD 'Python --version' returns Python 3.4, so unsure how to fix the issue. I installed these months ago, and may have put them in Downloads before transferring both to C:\ for clarity, which may be the problem but am unsure how to fix it.
Also, if your answer involves pip in any way please clarify how exactly to use pip in Windows. A lot of websites say to run eg. 'pip setup.py install' in the 'terminal' but do not specify if they mean Windows CMD terminal, IDLE GUI, or Python.exe command-line interface. Thanks a lot!
Not the answer to your actual question, but some clarification on your last point:
but do not specify if they mean Windows CMD terminal, IDLE GUI, or
Python.exe command-line interface.
Yes, this requires to know some context that a beginner may not have. The command pip is always used in the CMD terminal. So open CMD, and enter
pip3 install matplotlib
Notes:
Use pip3 when installing for Python 3. Then you're certain you're not accidentally installing libraries for Python 2.
pip setup.py install does not exist. You're mixing up two mechanisms to install Python packages/libraries:
One uses pip, with aforementioned pip3 install <something>. Pip goes looking online, finds a corresponding package name in a database, retrieves the URL for that package, downloads the package and installs the package. All in one command.
python3 setup.py install (again explicitly use python3 or python2 to be sure) requires you to find the package, download it, unzip it, and then in the CMD terminal, inside the unzipped folder, run the python3 setup.py install command.
This second method is usually for the latest-greatest version of a package that is not yet in pip's database, or for packages that never were in pip's database in the first place.
Generally, as a beginner, you want to stick with pip. If you ever run into the issue with the package not being available via pip, you may still be able to use pip for downloading and installing, like for example so:
pip install https://github.com/matplotlib/matplotlib/archive/master.zip
which would install the most recent matplotlib (which won't have even a version number yet, so bugs could be around).
All of these commands happen in the CMD terminal: downloading/installing packages generally all go through the terminal.
Also, when people mention "terminal", they will mean (for Windows) something like the CMD terminal. When it has to be done inside Python, it is generally called the "Python prompt". (IDLE is yet a different beast, that I'm not familiar with. I'm guessing that it has several parts, including a text editor section and a Python prompt section.)

pyinstaller --version failed to create a process

I would like to use PyInstaller to create a Windows executable. I installed pyinstaller using pip, as well as the correct version of pywin32.
When I attempt to verify the pyinstaller installation by typing pyinstaller --version, I get the message failed to create a process.
What am I doing wrong? Thanks in advance for your help.
There could be two reasons:
1) The python install location has spaces. See the answer at https://stackoverflow.com/a/34546220/3559967
2) You renamed the python install location. See the answer at https://stackoverflow.com/a/17560177/3559967
You can always reinstall pyinstaller:
python -m pip uninstall pyinstaller
[output of uninstall]
python -m pip install pyinstaller
where python is the command you use to run the python version of your choice (py, python, python3, etc.).
Notes:
Moving or changing exe names (i.e. the python.exe filename), folders, etc. can cause issues, per the other answer. If you want to make changes to the python exe or it's location, you typically need to do that immediately upon install, before installing any other packages.
There are ways of recording all your existing packages (See PIP Freeze) to a requirements.txt file, and then reinstalling them later, for another version of Python or to a new virtual environment.
If you are not familiar with virtual environments, you can start learning in the Python venv package docs. Note that you should never rename or move a venv folder after creating it (but it's easy to create a new one and reinstall the packages).

how to get spyder's python recognize external packages on MacOS X?

I have spyderlib installed on my MacOS X (10.6.8) using the official dmg file. In parallel, I have installed packages using both pip and homebrew from the terminal (i.e. opencv, gdal...). As Spyder is using its own python version, I cannot access my external packages within Spyder.
When Homebrew install a package, it instals it in the /usr/local/lib... directory, which is not avalaible to add using the Python Path manager of Spyder.The entire directory /usr/... is hidden.
The only relevant similar case I found online was the following:
Adding a module (Specifically pymorph) to Spyder (Python IDE)
I have tried unsuccessfuly their recommendations. So two related questions to tackle the problem:
1- would it be possible to actually use in Spyder the same python as the one accessed in the terminal?
2- otherwise, how to add external packages to the Spyder's original python, when the packages are installed in the folder /usr/local... ?
Thanks
I don't use a mac, but I would go with option 1, building and installing Spyder on your regular Python.
Install PyQt4 if you don't have it:
brew install pyqt
Then download the Spyder 2.2.5 source (spyder-2.2.5.zip) from here, unzip the folder where you like.
Then open a terminal, and go inside the Spyder source folder (you must input the next commands from inside this folder).
Then build using your regular python executable:
python setup.py build
and install:
python setup.py install
If all dependencies are met, you should then have Spyder as a package under your main Python installation. There should be a script to execute it under the Scripts folder.
You can also see "Install or run directly from source" from the main Spyder installation page.

How to install wexpect?

I'm running 32-bit Windows XP and trying to have Matlab communicate with Cgate, a command line program. I'd like to make this happen using wexpect, which is a port of Python's module pexpect to Windows. I'm having trouble installing or importing wexpect though. I've put wexpect in the folder Lib, along with all other modules. I can import those other modules but just not wexpect. Commands I've tried include:
import wexpect
import wexpect.py
python wexpect.py install
python wexpect.py install --home=~
wexpect install
Does anyone have anymore ideas?
If you installed wexpect somewhere in the module search path (sys.path), then import wexpect is what you would use. You have to make sure you installed it in the right path, though (the usual location is Lib\site-packages inside the Python installation.) If the package wexpect.py was in came with a setup.py file, you could install it with
\path\to\python setup.py install
from a DOS prompt. Depending on what else you did you may need to restart the Python interpreter or IDE that you're using for it to pick it up. You should also pay attention to the errors you get when you try import wexpect, as it may have dependencies you need to install.
Perhaps you haven't installed wexpect correctly.
In your command prompt (not python, but the DOS-like command shell), go to the directory where you downloaded wexpect. Make sure it's unzipped and you can see the setup.py file when you use the dir command.
Then enter the command (again, in the cmd shell, not the python terminal):
python setup.py install.
I have created a Github repo and PyPI project for wexpect. So now wexpect can be installed with:
pip install wexpect

Categories

Resources