I'm using mac OsX 10.8.2, pyCharm 2.7.1. python 2.7.2
I want to use pygame package with pycharm. I followed the instructions on the pygame site and installed pygame 1.9.1 successfully.
When I write "import pygame" pycharm doesn't find the package.
I tried installing the latest updates of python, pycharm and pygame. I tried using the "install" window in the preferences. It installed "pygamess", "pygameui" and "pyviewx.pygame", but when I try to instal "pygame_loaders" it writes "Install packages failed: Error occurred when installing package pygame_loaders".
If you can please give simple instruction since I'm not a heavy mac-user.
To use pygame under OS X, you need to run Python under the 32 bit interpreter. It's usually called something like 'python2.7-32', and if installed from the package on http://www.python.org/, within /usr/local/bin
To get this working in PyCharm, open a project, then preferences ('apple'-'comma'), go to 'python interpreters', and click the '+' button in the right hand pane.
A list should appear and you'll see '/usr/local/bin/python2.7-32', select that and then make it the default for your PyGame project.
If you haven't installed Python from python.org, I recommend you do so; the current version is 2.7.3.
The above setup is how I got PyGame working in PyCharm on Sunday, so it should still be valid.
If you have a 2.7 virtualenvs running inside pyCharm you can manual install pygame.
Navigate to the virtual env on you disk via the terminal:
cd ~/.virtualenvs/Pygame
Or whatever directory you have. Now we active the virtualenv, just like we normal do when we not work inside pyCharm.
source ./bin/acivate
You should see something like this
(Pygame)mbp-2:Pygame pietje$
Now we can install pygame inside this env.
pip install hg+http://bitbucket.org/pygame/pygame
That's it and everything should work fine inside PyCharm. It does work on my machine :)
Related
I am struggling with getting pygame to work on VS Code. The only thing that seems to be amiss is that these are different versions and they are in different folders:
PS C:\Users\rebec\My Drive\VS Code\Python Config> python --version
Python 3.9.11
PS C:\Users\rebec\My Drive\VS Code\Python Config> pip --version
pip 22.1.2 from C:\Users\rebec\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pip (python 3.10)
I have tried uninstalling and installing pygame. I think it's something with the file configs but I just don't know how to fix it. Thanks in advance for the help!
You have two versions of python installed on your computer. One is 3.9.11, and another is 3.10. You installed pygame for python 3.10, and tried to run it with python 3.9.11.
If you want to run your game using the global interpreter (python 3.10, the one where you installed pygame), you will need to switch your interpreter inside VSCode:
Press Ctrl+Shift+P to open a command pallete.
Open Python: Select interpreter.
Set your interpreter to global one.
You might also want to consider using a virtual enviroment to avoid problems like these in the future:
Each virtual environment has its own Python binary (allowing creation of environments with various Python versions) and can have its own independent set of installed Python packages in its site directories, but shares the standard library with the base installed Python.
im very new to code in general so this could be a stupid beginner problem ive searched for things but i couldnt find something useful for me
under Problems is the message: Import "pygame" could not be resolved
You can use pip show pygame to view the package installed location.
And check whether the installation location is consistent with the version corresponding to the selected Python interpreter.
There are two ways to solve this problem:
"ctrl+shift+P" and change the python interpreter.
If you don't want to change the interpreter, you can use pip -t flodername pygame #flodername is your used python package location. Install the pygame package to the specified directory
First, try restarting your computer or vs code
Use this command in your vs code terminal if the above doesn't work:
pip uninstall pygame
Then reinstall pygame using:
pip install pygame
If this also does not work then follow these steps:
Go to the scripts folder of python.
Open command prompt or Powershell in the script folder.
Use this:
C:\python34\scripts> python -m pip install pygame
Done
As an Anaconda user, I found my packages were being installed to C:\Users\YOUR_USERNAME\anaconda3\Lib\site-packages, which Visual Studio Code was not picking up on.
With the Pylance extension installed, open Settings (File > Preferences > Settings, or Ctrl+,)
At the top, beside Workspace, choose User
Under Extensions > Pylance, scroll until you find Python › Analysis: Extra Paths and select Add item.
Type in the path to which packages are being stored (in this case, C:\Users\YOUR_USERNAME\anaconda3\Lib\site-packages)
Click OK and after a couple moments, you should see something like the below image (i.e, the path is included in the list of paths).
Finally, your Python file should have picked up on the changes, but if not, reload it or VS Code. If nothing else, add another path that packages are being saved to or change your Python Interpreter. Using another virtual environment's interpreter wouldn't be very helpful, after all.
I may be late, but I hope this helped.
I have installed Spyder using pip (after realising that Anaconda gave me issues with my Windows username containing a space).
Pip says it is installed and up to date but if I try to launch it via CMD using "spyder" or "spyder3", cmd does not recognise the command.
I also cannot find it anywhere in the python folder.
This is bizarre, has anyone got any solution?
Thank you
PS I'm running Windows 10 with Python 3.8 and currently use PyCharm
I had a similar problem with pygame and pyinstaller, did you update your paths? Make sure to add C:\Users\YourUsername\AppData\Local\Programs\Python\Python38-32\Scripts
that's where my mine are installed
I have a VM running only Anaconda. There are no other available installations of Python. This is all I see when I run "Apps and Features" in Windows 10 and filter for Python (note that it is Python 3.7.4):
When I go to the Conda prompt and enter conda list, I see that I have openCV installed :
but it's with a version of Python 3.7.6:
However when I open VS Code and I set my Python Path to the version in the Anaconda folder: (C:\Users\Me\Anaconda3\Python.exe) and try to import OpenCV, I get the "module not found" error. When I create a new python file and run
help("modules")
I do not see OpenCV in the list below in the terminal even though its installed.
Any idea how this is happening? I just don't see a second installation of Python on my PC, but why am I seeing 3.7.4 and 3.7.6 and is this possibly causing my issue?
Edit: Added a picture of the error I get when trying to run it.
Install anaconda plugin in VSCode and select your conda environment in the bottom left of VSCode window.
If you didn't create a conda environment, the you will probably have installed the package in the base environment.
Edit: Reading the PyPi project, I found the right way to import opencv in python code.
import cv2
I have downloaded the py-earth module from GitHub and followed the provided installation procedures as well as done "pip install". Things seem to be installing in the terminal, but I cant find the module when I am in pycharm. I have restarted pycharm, reinstalled, and no matter what I can't find a way to install the module. Please help
Have you gone into your settings and set your project interpreter in settings > Project: {project-name}> Project Interpreter to your version of python that has the module you installed?
From pycharm,
goto settings -> project Interpreter
Click on + button on top right corner and you will get pop-up window of Available packages. Then search for earth python package.
Then click on Install package to install the earth package.