Installing PyAutoGui on multiple versions of Python - python

I, as it will soon be obvious, am a total newb when it comes to Python.
I am running python version 3.5 on Windows 10, 64 bit.
I installed the PyAutoGui module for a small project I am working on. At first, everything worked perfectly. But now it appears that PyAutoGui is crashing when it clicks. I suspect that it's because PyAutoGui is only intended for use up to Python 3.4.
In order to rectify this, I downloaded Python 3.4. Unfortunately, however, when I try to install PyAutoGui (using pip install pyautogui), it tells me that it's already been installed because it sees it in the Python 3.5 folder.
My question is this: How do I install PyAutoGui in Python 3.4 with it already installed in Python 3.5?
Assume that I know virtually nothing about how to install a module manually without using pip
Thanks in advance!

If you have multiple versions of Python installed you need to find your versions and rename them and their Pips.
In windows the path is, C:\\Users\USERNAME\AppData\Local\Programs\Python\Python3x-32. The x should be replaced with the Python version and USERNAME with your username. On Mac it's located in /usr/local/bin/python. On Linux it should be in /usr/bin/python. The location might vary depending on OS and Python version.
Rename the files python.exe/python and pip.exe/pip so that each file is different. I named mine python35.exe, python2.exe and python.exe(for 3.5, 2.7 and 3.6).
Now when you execute your pip command use, pip34 install pyautogui or whatever you named the file.
Or if you really want to you can go the painful way of renaming all the path variables, but I won't explain that here.

Related

Install python 2.6 on Mac

I have to use an API which uses Python 2.6 and am having a very difficult time getting it installed on my mac. I have downloaded it but figuring out what I am supposed to write in my bash_profile is exceedingly difficult. For all versions of Python that I have used so far I write
PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"
export Path
in my bash profile. But I can't do that for python 2.6 because it does not have a bin folder. Does anyone know what I'm suppoed to write on my bash profile in order to get Python to use version 2.6?
I'm aware that one solution is pyenv but I tried that a long time ago and there were too many modules that I could not install with it so I don't like that program.
I'm also hoping brew will work but according to this page
https://formulae.brew.sh/formula/
python 2.6 is no longer available for brew install. And when I run brew install python#2.6 no formulae are found.
My current strategy is to try macports so we'll see how that goes.

ImportError when changing Python interpreter

I have been using PyCharm on Ubuntu to run some Python code, where in Edit Configurations I specified the interpreter path as /usr/bin/python2.7. The code uses the pygame module, and so to install this, I also ran sudo pip install pygame. Then I used import pygame in my Python script, and the file ran ok.
However, I now want to use Python 3.4. So, in PyCharm, I specified the interpreter path to be /usr/bin/python3.4. However, when I run the same file, I now get the error: ImportError: No module named 'pygame'.
Can somebody explain why this is happening? How can I get my Python 3.4 interpreter to find Pygame?
Thanks!
Each python installation has a separate set of libraries. Your python 3 does not know about Python 2 and its libraries. It seems the default pip command calls the python2 pip script. Run again the pip install, but with the python3 pip (look for it in your python3 folder, it is probably named pip3)
As others have pointed out, different Python installations will maintain their own independent set of libraries. Bear in mind that you can install packages from the same window that you use to change the interpreter in PyCharm for a project. You might find that more convenient if you're switching between interpreters.
You just click the green 'plus' icon to do so:
pygame has different releases for each version of Python.
As you have the Python 2.7 module and want to upgrade to Python 3.4, you'll need to reinstall pygame using Python 3.4 instead, you can using pip again or you can download files from here: http://www.pygame.org/download.shtml.

How do I get python to import pandas?

I installed Python 3.5.1 from www.python.org. Everything works great. Except that you can't install pandas using pip (it needs visualstudio to compile, which I don't have). So I installed Anaconda (www.continuum.io/downloads). Now I can see pandas as part of the list of installed modules, but when I run python programs I still get:
ImportError: No module named 'pandas'
How do I set up my environment to use the modules from Anaconda?
Note: I have Anaconda's home directory and Library/bin on my path, as well as Python's home directory. I do not have PYTHONPATH or PYTHONHOME set, and I know I have the correct privileges to see everything.
I have successfully installed pandas for a Windows 32 bit version Python 3.4 with pre-complied code (no Visual Studio required) using the website:
http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyyaml
There is link for Python 3.5 pre-complied code at this site as well, but I have not tested it.
Download the code you want to a directory on your machine.
Using your Windows CMD.exe, go to your python directory and enter:
Python -w pip install "YourDirectory/pandas-0.18.1-cp35-cp35m-win32.whl"
OR
Python -w pip install "YourDirectory/pandas-0.18.1-cp35-cp35m-win_amd64.whl
Choose the version based on the version of Python you have
have, 32 bit or 64 bit.
Good Luck!
Anaconda has included one version of Python with it. You have to change your system environment path with Anaconda's instead of the former one to avoid conflict. Also, if you want to make the whole process easy, it is recommended to use PyCharm, and it will ask you to choose the Python interpreter you want.

Python not installing on Yosemite

I think I kinda made a mess here. I installed the 2.x version of Python for os x and then I realized that I needed to install the 3.x. So I downloaded the pkg for 3.x too and installed. While coding I realized that the terminal and everything was still using the 2.x version. So I looked in the internet a way to uninstall it and I ended up for deleting some bin files which made the terminal not working. I repaired the permissions from Utility Disk, installed Python 3.x again, but no command for Python seems to be working. And no Python's file is added to the bin folder. Any help?

Installing Pillow for Python on Windows

I am fairly new to Python and trying to install the Pillow package on Windows 7. I downloaded and ran the MS Windows installer Pillow-2.2.1.win-amd64-py3.3.exe from here. It appeared to install fine. If I run the simple line of code:
from PIL import Image
directly from the Python interpreter, it runs fine. A help() on PIL gives me the package contents.
But when I try to run the same line of code from within a script, I get an ImportError: No module named PIL. What am I missing?
(Note that I've been able to import sys and import MySQLdb from within scripts just fine.)
Resolved: sure, enough, I'm running Python 2.7 when I run scripts. (I think I vaguely recall having to install an older version so I could interface with MySQL.) Thank you all for pointing out that I should check the version being used.
For third-party modules for Windows, my go-to resource is Christoph Gohlke's Python Extension Packages for Windows. You can find the latest version of Pillow here. Make sure you're working with the python.org version of Python.
As far as your specific error, it's hard to tell exactly without a traceback, but make sure your script is calling the correct version of Python. If you have also installed Python 2.7, for example, your script may be calling that instead of 3.3.
In such cases I'm simply printing the sys.path at the beginning of the script in trouble and comparing it with the one from the working python interpreter. In most cases I was running the script with a different python interpreter.
In my case , I was referring to wrong pip folder.
Changed virtual environment in pycharm to point to right pip folder to solve this issue
import sys
print ( sys.path )

Categories