When I download pygame-1.9.2b8-cp36-cp36m-win32.whl from http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame I turn it into zip, take the headers in the pygame-1.9.2b8.data folder into pygame34/include/pygame and I put the other pygame file from the zip in the site-packages folder together with pygame-1.9.2b8.data as any tutorial shows, I always get this error:
Traceback (most recent call last):
File "C:/Users/andsa/PycharmProjects/THIS WORKS ANDREAS/Games.py", line 1, in <module>
import pygame
File "C:\Python34\lib\site-packages\pygame\__init__.py", line 141, in <module>
from pygame.base import *
ImportError: No module named 'pygame.base'
EDIT: I use python 3.4.5, I have tried both python and pygame 64 and 32 bit but i still get this error
This error bugged me for months, what i did was:
Uninstalled the package
pip3 uninstall pygame
Purged the pip cache
pip cache purge
Finally...Reinstalled pygame using pip3
pip3 install pygame
Worked like a charm :)
Use pip3 tool to reinstall the pygame python module:
C:\Python373\Scripts>pip3 uninstall pygame
C:\Python373\Scripts>pip3 install pygame
Then install it:
C:\Python373\Scripts>pip install pygame-menu==2.0.1
You probably have python installed for 32-bit. Uninstall and the install the 64-bit version. After that,
pip3 uninstall pygame
pip3 install pygame
try usin pip3 install pygames
to install pygames
pip3 install pygame
SUBLIME TEXT SOLUTION
OBS: THE REASON MOST GUI FRAMEWORKS DO NOT WORK ON SUBLIME IS BECAUSE OF THIS ONE LITTLE DETAIL HERE
Create a new build system:
In Sublime go to >> Tools
Tools >> Build System
Build System >> New Build System
DELETE EVERYTHING CONTAINED IN THIS NEW FILE AND ADD THIS PIECE OF CODE:
{
"cmd": ["/usr/local/bin/python3.8", "-u", "$file"],
"file_regex": "^[]*File \"(...*?)\", line ([0-9]*)"
}
ATTENTION: DO NOT CHANGE THE CURRENT DIRECTORY YOU ARE ON, WHICH IS THE
USER ONE.
SAVE IT AS Python3.8.sublime-build
In Sublime go to >> Tools
Tools >> Build System
Mark the Python3.8 you have just created
Voila!
P.S I Saved mine as 3.7 but it works the same, as long as the code inside the file is 3.8, or whatever version you have on your machine currently.
Related
I've used the following tutorial to install Python, numpy, scipy and matplotlib:
https://penandpants.com/2012/03/01/install-python-2/
I downloaded each and installed by double-clicking. I'm using a Mac with OS X Yosemite Version 10.10.5
When I try to import numpy, scipy and matplotlib in IDLE I get the follow error message:
`>>> import numpy
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
import numpy
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/__init__.py", line 137, in <module>
import add_newdocs
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/add_newdocs.py", line 9, in <module>
from numpy.lib import add_newdoc
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/lib/__init__.py", line 4, in <module>
from type_check import *
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/lib/type_check.py", line 8, in <module>
import numpy.core.numeric as _nx
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/__init__.py", line 5, in <module>
import multiarray
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/multiarray.so, 2): no suitable image found. Did find:
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/multiarray.so: no matching architecture in universal wrapper`
Can anyone please explain to me how to resolve this?
Thanks
use terminal and type
sudo pip install numpy
sudo pip install matplotlib
sudo pip install scipy
for python3+ use pip3
I can't say for sure what's wrong with your installation, but I suspect it's due to a some PATH-conusion... Python 2.7 and Numpy should be installed on your Mac by default.
If you run the command which python, you'll see which executable the python-commands invokes... is it the same as the one you installed?
If you write python in the terminal, and press tab twice, do you see multiple options of installed python versions?
Alternative method of installation
I prefer the Anaconda Python Distribution, which you can download like the full version or minimal version, which is the one I prefer.
If you install this, you should consider uninstalling the one you just installed.
Here's how to install the mini version:
Download the installer, and run it by opening a terminal in the folder with the installer, and running the command bash Miniconda2-latest-MacOSX-x86_64.sh. This will start the text-based installer, and if you read the instructions on screen, you'll be fine.
Notice that you have to scroll to the end of the licence agreement, before you can write yes when asked to accept the terms stated.
Say yes when it asked you if you'd like it to add Anaconda Python to your path.
Anaconda Python is different from other python distributions in the regard that it comes with it's own package and environment manager conda. With conda you can have multiple versions of Python installed at the same time (or several environments of the same Python version, but with different packages or versions of packages).
To create a new environment with the name py27, which is using Python 2.7, write conda create -n py27 python=2.7 --yes. Once created, activate the environment by source activate py27.
With the new environment now active, install the packages you need by using conda: conda install scipy matplotlib --yes.
I'd also recommend installing Ipython, which is an improved shell, and possibly the Jupyter notebook: conda install ipython --yes and conda install notebook --yes.
Hope it helps.
I have pygame 1.9.2 for Python 3.2+. However, when I try to start up Python with pygame, I receive: "ImportError: DLL load failed: The specified module could not be found." I found the files it needs, but where should I put them?
This is my full error traceback:
Traceback (most recent call last):
File "C:\Users\Owner\AppData\Local\Programs\Python\Python36-32\hg.py", line 1, in <module>
import pygame
File "C:\Users\Owner\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pygame\__init__.py", line 95, in <module>
from pygame.base import *
ImportError: DLL load failed: The specified module could not be found.
Most pygame errors in windows 10 are caused by having an out-of-date pygame by installing the compiled .exe version while not installing it from the official source, since their version is different from the PyPi index.
You will have to download the corresponding file suitable for your system from here:
http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame
Then do
pip install c:/path/to/the/wheelfile.whl
You must have installed pygame incorrectly or something went wrong during installation. I would uninstall pygame and reinstall it with the pip command.
Go to the search bar at the bottom left of your desktop (on your taskbar) and enter cmd. This will open the command line interface (CLI). Then go to here: https://pip.pypa.io/en/stable/installing/ and install the file get-pip.py. Once this has been completed, go to the cmd you opened earlier and enter python get-pip.py. This should install pip, setuptools and wheel.
After this, use the command below to install pygame:
pip install pygame
Then try a simple test to see if it works:
import pygame
print(pygame)
I've looked at a number of posts on this and nothing seems to fix it. I initally started out on Python 3.5, heard that there were several unresolved issues with pip and so I uninstalled and reinstalled Python 3.4.4 -
I want to use pyautogui for a work task, but when I try to install pyautogui directly after Python3.4.4 installation it tells me the PIL Module can't be found. I read in another article to install 3.4.4 and update pip, then install pyautogui. Cool, so I installed 3.4.4, I needed to upgrade pip. So I entered in
Scripts\pip.exe install --upgrade pip
from the command line in the root folder. Every time I get this
Exception:
Traceback (most recent call last):
File "h:\python34\lib\shutil.py", line 527, in move
os.rename(src, real_dst)
PermissionError: [WinError 32] The process cannot access the file because it is
being used by another process: 'h:\\python34\\scripts\\pip.exe' -> 'C:\\Users\\z
jf\\AppData\\Local\\Temp\\pip-qo75adq9-uninstall\\python34\\scripts\\pip.exe'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "h:\python34\lib\site-packages\pip\basecommand.py", line 211, in main
File "h:\python34\lib\site-packages\pip\commands\install.py", line 311, in run
File "h:\python34\lib\site-packages\pip\req\req_set.py", line 640, in install
File "h:\python34\lib\site-packages\pip\req\req_install.py", line 716, in unin
stall
File "h:\python34\lib\site-packages\pip\req\req_uninstall.py", line 125, in re
move
File "h:\python34\lib\site-packages\pip\utils\__init__.py", line 315, in renam
es
File "h:\python34\lib\shutil.py", line 540, in move
os.unlink(src)
PermissionError: [WinError 32] The process cannot access the file because it is
being used by another process: 'h:\\python34\\scripts\\pip.exe'
Thing is, nothing is running in that folder. I don't have windows explorer open to it, I don't have anything accessing any files in there, and I'm obviously running it from an upper level directory using the command line. So I have no idea why it's saying that pip.exe is being used by another process. The only process it's being run by is itself and if that's the issue, then how in the world are you supposed to upgrade it?
**EDIT: ** Per the accepted answer, in order to get PIP to update I used the command
python -m pip install -U pip
Once that worked I tried to install pyautogui yet again. It still said that PIL module could not be found. PIL is the Python Image Library. I installed it using
python -m pip install image
And once that worked I then installed pyautogui like so
python -m pip install pyautogui
To upgrade pip on windows google "upgrade pip on windows" or alternately run this in a command prompt:
python -m pip install -U pip
This is a known issue on windows where an executable can't be overwritten while it's running. Sorry no links handy but it should be easy to find more details.
Problem: You are using pip version 18.1, however version 19.0.1 is available. You should consider upgrading via the ‘python -m pip install –upgrade pip’ command.
Solution: In order to upgrade PIP in Windows, you’ll need to open the Windows Command Prompt, and then type/copy the command below. Note that the following method would only work if you already added Python to Windows path. Don’t worry if you don’t know what it means, as I’ll show the full steps to upgrade pip in windows in the next section.
python -m pip install --upgrade pip
I just installed Gubbins using their homebrew instructions. Everything seemed to go smoothly and gubbins is now in /usr/local/Cellar/gubbins/1.1.1/bin/gubbins. I'm supposed to be able to use it by running their script run_gubbins.py and giving it an input file. But I get the following error:
>$ /usr/local/Cellar/gubbins/1.1.1/usr/bin/run_gubbins.py test.fasta
Traceback (most recent call last):
File "/usr/local/Cellar/gubbins/1.1.1/usr/bin/run_gubbins.py", line 25, in <module>
from gubbins import common
ImportError: No module named gubbins
Looking inside the run_gubbins.py script I see that the first things it does is
import sys
sys.path.append(".")
import argparse
from gubbins import common
So what might be happening? How come the script within a program package is not recognizing the program it came with? Is there anything I can do to fix this? Thank you so much.
Install homebrew from brew.sh
Open a terminal and enter these commands
curl https://bootstrap.pypa.io/ez_setup.py | python - --user
export PATH=~/Library/Python/2.7/bin:${PATH}
easy_install pip
pip install --user dendropy
pip install --user biopython
pip install --user reportlab
brew tap homebrew/science
brew install http://sanger-pathogens.github.io/gubbins/fastml.rb
brew install http://sanger-pathogens.github.io/gubbins/gubbins.rb
I installed a new module and it appears as if one of its dependencies was not already installed. The module is called Xlib.display.
Here is the error message I received:
from Xlib.display import Display
ImportError: No module named Xlib.display
Where can I find this module that I am apparently lacking? Google yielded no leads.
"Edit: I already have that sourceforge module downloaded but I still get the same results.
Please try.
This shall install Xlib
sudo apt-get install python-xlib
Then you can check
>>from Xlib.display import Display
To install PyMouse if you want to control and capture mouse events please use:
sudo easy_install https://github.com/pepijndevos/PyMouse/zipball/master
Below worked for me!
pip install python3_xlib
I have also used pyuserinput for automation which requires this.
I was having the same problem, but the solutions above didn't work for me. Since I had installed python through the anaconda package, when I used:
sudo apt-get install python-xlib
Xlib was still undetectable by python2. The solution in my case was to use:
anaconda search -t conda python-xlib
Then find the package from the anaconda api, mine was erik/python-xlib. Install it using:
conda install --channel https://conda.anaconda.org/erik python-xlib
Then it worked.
On Debian systems install python-xlib.
On other systems there's a high probability that the package carries the same name.
I don't think the Xlib library works in Python 3.
Source:
Requirements
The Python X Library requires Python 1.5.2 or newer. It has been tested to various extents with Python 1.5.2 and 2.0 through 2.6.
I honestly cant explain why this works... but here is the command that got it working for me.
sudo apt-get install python3-xlib
Should not work because xlib apparently does not work with python 3.x, but everything installed alright, so I'm not complaining!
I was looking for the same answer, however after some more digging it seems that XCB (X protocol C-language Binding) will obsolete Xlib in general. From the XCB website:
The X protocol C-language Binding (XCB) is a replacement for Xlib featuring a small footprint, latency hiding, direct access to the protocol, improved threading support, and extensibility.
Fortunately there are python bindings available as python-xpyb in apt or xpyb on PyPi. I've not gotten that far in my project so I haven't tested if this works with Python3, but this is probably the way to go and the proper place to file any Python3 support bugs if necessary.
Scenario:
I was trying to use screenshot functionalities of pyautogui package. I was getting this error:
Traceback (most recent call last):
File "test_screenshot.py", line 1, in <module>
import pyautogui
File ".../miniconda3/envs/myenv/lib/python3.7/site-packages/pyautogui/__init__.py", line 152, in <module>
from . import _pyautogui_x11 as platformModule
File ".../miniconda3/envs/myenv/lib/python3.7/site-packages/pyautogui/_pyautogui_x11.py", line 7, in <module>
from Xlib.display import Display
ModuleNotFoundError: No module named 'Xlib'
Python code (test_screenshot.py):
import pyautogui
img = pyautogui.screenshot('test.png')
Environment:
Ubuntu 16.04 (LTS)
conda 4.5.11
Python 3.7 (Miniconda)
requirements.txt:
certifi==2019.3.9
Pillow==5.4.1
PyAutoGUI==0.9.42
PyGetWindow==0.0.4
PyMsgBox==1.0.6
PyRect==0.1.4
PyScreeze==0.1.20
PyTweening==1.0.3
Solution:
I installed python-xlib package in the conda environment using:
pip install python-xlib
Now test_screenshot.py is running without any error.
Updated requirements.txt:
certifi==2019.3.9
Pillow==5.4.1
PyAutoGUI==0.9.42
PyGetWindow==0.0.4
PyMsgBox==1.0.6
PyRect==0.1.4
PyScreeze==0.1.20
python-xlib==0.25
PyTweening==1.0.3
six==1.12.0