Failed to unpack the installation folder - python

I am trying to follow an Adafruit tutorial which requires installing pySerial. I am running mac 10.8 and run into this error when I try to unpack the installation folder. I go to the directory the file is placed and type:
tar -xzf pyserial-2.6.tar.gz
And then the terminal prints:
tar: Error opening archive: Failed to open 'pyserial-2.6.tar.gz'
I can't seem to find what I could be doing wrong, so any advice would be appreciated.
For those looking for the tutorial, the link can be found here: http://learn.adafruit.com/arduino-lesson-17-email-sending-movement-detector/installing-python-and-pyserial

When this error occurs. It usually means that the file cannot be found. At command line of your Terminal enter "cd downloads" and search for file pyserial-2.6.tar.gz. If the file is found, proceed by entering tar -xzf pyserial-2.6.tar.gz.

If you don't understand the terminal—or even if you do—you're going to be a lot happier using pip or easy_install than trying to do this manually. pip is better, but doesn't come built in with Apple's Python, so you'll have to install it first. Fortunately, that's pretty easy. So, let's do that:
$ sudo easy_install pip
And now:
$ sudo pip install pyserial
That will automatically download, build, and install the package for you, without you having to know anything about what directory things get downloaded to or how to run the tar command properly or anything.
And let's test it just to make sure:
$ python
Python 2.7.2 (blah blah blah … )
>>> import serial
>>> serial.VERSION
'2.6'

Related

Installing PIP on Windows 10 python 3.5

I just started learning Python, and successfully downloaded Python 3.5. I attempted to download/upgrade PIP 8.1.2 multiple times using get-pip.py, which I ran (successfully I think) but when I attempted to execute python get-pip.py
I got the error code:
File "<stdin>", line 1
python get-pip.py
^
SyntaxError: invalid syntax
I understand that pip is included in python but the pip website requires users to upgrade pip which I don't think I can since any pip commands lead to syntax errors, and do not produce the same output that most tutorial sites show. I have tried to find different ways to fix it, but I can't figure out whats wrong aside from pip not being on the computer in the first place or corrupted. Thank you for your assistance.
You won't need to upgrade pip if you just downloaded python 3.5, go to where you have your Python3.5 file and open the folder Scripts, you will find pip.exe. Open powershell and use the cd command to move to the folder containing pip.exe. From here you can use pip install to get modules.
Open Windows Powershell
PS C:Users\you> cd C:\path\to\scripts\folder\containing\pip
PS C:\path\to\scripts\folder\containing\pip> pip install module
Not sure what you are asking. If you want to run python get-pip.py do it in a windows command prompt, not in the python interpreter. But I do not know why you would want to do that.
You already have pip; there is no need to run get-pip. Upgrading can be done by pip itself.
But the reason you are getting errors is that all these commands, including pip itself, should be run at the command line, not in the Python interpreter.

Cannot import visa after installing pyvisa on Mac OS X

I installed python with homebrew and installed pyvisa with pip, now when I run import visa, I got the following error:
OSError: dlopen(/usr/local/vxipnp/linux/bin/libvisa.so.7, 6): image not found
It seems like it's looking for NI-VISA at wrong location, how can I fix this?
On the pyvisa website FAQ it says
Error: Image not found
This error occurs when you have provided an invalid path for the VISA library. Check that the path provided to the constructor or in the configuration file
But how do I check the path?
The file that needs modification is vpp43.py.
However, the packages of PyVISA installed from 'pip' or 'easy_install' on Mac OS will be installed under .egg file:
$ /Library/Python/2.7/site-packages/PyVISA-1.5.dev4-py2.7.egg
I could not find a way to modify this, therefore I recompiled the original code by downloading it in a given director
$ mkdir pyvisacode
$ cd pyvisacode
$ curl -OL https://github.com/hgrecco/pyvisa/tarball/master
When it is downloaded extract it by
$ tar -zxvf master
A file will be created in the same directory. Navigate to
$ cd hgrecco-pyvisa-4cbdbc9/pyvisa/legacy
and run Xcode or any other text editor
$ open -a Xcode vpp43.py
In the opened vpp43.py find
path = "/usr/local/vxipnp/linux/bin/libvisa.so.7"
Comment this line and replace it with
#path = "/usr/local/vxipnp/linux/bin/libvisa.so.7"
path = "/Library/Frameworks/visa.framework/visa"
Now you can install PyVISA by
$ cd ../../
$ sudo python setup.py install
Don't forget to run your python in 32 bit. More details can be found here http://bardagjy.com/?p=1245.
I hope this will be fixed in the next PyVISA update!
Good luck

How do I install pip in python 2.7?

My end goal is to install the requests module, and the way to do that seems to be with pip. I have looked through the pip install documentation here http://www.pip-installer.org/en/latest/installing.html
The documentation has offered me no help. It tells me to "securely download get-pyp.py". I have been searching for a way to do this, and so far, everything I have seen recommends the command
curl --silent --show-error --retry 5 https://raw.github.com/pypa/pip/master/contrib/get-pip.py | sudo python2.7
I have been unable to figure out how to use this command. Curl is not a python command. I installed curl for windows and ran this command in windows command line, which worked, but I was unable to proceed from there. Is this intended to be installed with windows command line, or something else? I am lost.
You can first install easy_install (which is part of set up tools) from the following location
https://pypi.python.org/pypi/setuptools#windows
Right click on the link and save the file ez_setup.py and then run it.
Once that is complete and you have added the scripts to your path variable (C...Python2.7..scripts), you can install pip using
easy_install pip
Check out this video for more help.
http://www.youtube.com/watch?v=MIHYflJwyLk&feature=youtu.be
Download the correct version from here: http://www.lfd.uci.edu/~gohlke/pythonlibs/#pip
And can find more info in this question: How do I install pip on Windows?

Help "Install" Module for Python using WGET

I am trying to setup this python library and am having a very hard time. I suspect it is because I am a hobby programmer, but I have successfully installed programs in the past using the command line. I am using Windows and Python 2.6.
The help that is shown below is taken from the website.
wget http://pypi.python.org/packages/source/y/yql/yql-0.2.tar.gz
tar -xzf yql-0.2.tar.gz
cd yql-0.2
python setup.py install
In doing a number of Google searches, it seems that this is for Unix/Mac commands. My previous process has not worked, so I am looking for all of the help I can get.
Many thanks in advance!
Brock
Here is the error:
>>> import yql
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "c:\python25\lib\site-packages\yql-0.6-py2.5.egg\yql\__init__.py", line 201, in <module>
class Public(object):
File "c:\python25\lib\site-packages\yql-0.6-py2.5.egg\yql\__init__.py", line 229, in Public
#scheme.setter
AttributeError: 'property' object has no attribute 'setter'
Those are definately Unix/Linux commands to install python module. The installation in windows is pretty much similar. Follow the instructions given below
Download the library from the website.
Extract it using Winzip or WinRAR.
It will create a directory with name like foo-0.2. The directory should contain a script named setup.py
Now open the command prompt and cd to that directory
At command prompt type following
python setup.py install
Also check the following link for more detailed instructions
http://docs.python.org/release/2.6/install/index.html
What's the error message? Also what OS are you using? The install instructions seem fine.
In Debian & in most Unix Systems you could also these -
sudo pip install <module_name> to install any module.
or sudo easy_install <module_name>
or sudo apt-get install <module_name>
or you could do what you mentioned in the question. Should work fine.
Maybe you don't have root access. Package installation needs that. Post more info for more constructive comments. All the best.
If you install setuptools first (see setuptools on pypi) and add C:\Python26\Scripts to your PATH variable you can run the following:
easy_install yql-0.2.tar.gz
after wgetting the archive.
Or even easier, without wgetting the archive, simply run:
easy_install yql
And it'll download and install the latest version of yql with all the dependencies.
The above answer for installing wget is to download wget for Python.
Download the tar file and unpack the file
Then cd to the folder and run in terminal
python setup.py install
This is to install wget into Python
Try this
import tensorflow
word2vec_path = 'YOUR LINK HERE'
word2vec = models.KeyedVectors.load_word2vec_format(word2vec_path, binary=True)

How to build sqlite for Python 2.4?

I would like to use pysqlite interface between Python and sdlite database. I have already Python and SQLite on my computer. But I have troubles with installation of pysqlite. During the installation I get the following error message:
error: command 'gcc' failed with exit status 1
As far as I understood the problems appears because version of my Python is 2.4.3 and SQLite is integrated in Python since 2.5. However, I also found out that it IS possible to build sqlite for Python 2.4 (using some tricks, probably).
Does anybody know how to build sqlite for Python 2.4?
As another option I could try to install higher version of Python. However I do not have root privileges. Does anybody know what will be the easiest way to solve the problem (build SQLite fro Python 2.4, or install newer version of Python)? I have to mention that I would not like to overwrite the old version version of Python.
Thank you in advance.
You can download and install Python to your home directory.
$ cd
$ mkdir opt
$ mkdir downloads
$ cd downloads
$ wget http://www.python.org/ftp/python/2.6.2/Python-2.6.2.tgz
$ tar xvzf Python-2.6.2.tgz
$ cd Python-2.6.2
$ ./configure --prefix=$HOME/opt/ --enable-unicode=ucs4
$ make
$ make install
Then, (if you are using bash) in your .bash_profile do
export PATH=$HOME/opt/bin/:$PATH
export PYTHONPATH=$HOME/opt/lib:$HOME/opt/lib/site-packages:$PYTHONPATH
Then, source the file to make it available
$ cd
$ source .bash_profile
$ python -V
where python -V will return the python version. If the correct version appears, any packages that you run with Python's setup.py util (assuming the developer followed the correct conventions) will install in ~/opt/lib/python2.x/site-packages directory.
Download pysqlite here, cd into the directory you downloaded to, unpack the tarball:
$ tar xzf pysqlite-2.5.5.tar.gz
then just do (if your permissions are set right for this; may need sudo otherwise):
$ cd pysqlite-2.5.5
$ python2.4 setup.py install
one error does appear in the copious output:
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/pysqlite2/test/py25tests.py", line 48
with self.con:
^
SyntaxError: invalid syntax
since as clearly shown that file is for py 2.5 tests only (with statement not present in 2.4!-). Nevertheless the install is successful:
$ python2.4 -c'import pysqlite2'
$
All this is on Mac OS X 10.5 but using python2.4 separately installed from the system-supplied Python 2.5.
The error you report doesn't tell us much -- maybe you're missing the headers or libraries for sqlite itself? Can you show us other output lines around that single error msg...?
If you don't have root privileges, I would recommend installing a more recent version of Python in your home directory and then adding your local version to your PATH. It seems easier to go that direction than to try to make sqlite work with an old version of Python.
You will also be doing yourself a favor by using a recent version of Python, because you'll have access to the numerous recent improvements in the language.
I had the same trouble with gcc failing with Ubuntu Karmic. I fixed this by installing the python-dev package. In my case, I'm working with python2.4, so I installed the python2.4-dev package. The python-dev package should work for python2.6.

Categories

Resources