My python installation is a mess.
Therefore I'd like to reinstall the entire installation of it. (Unfortunately,) I've also installed QGIS and PyCharm (mostly making it a mess) and I want to start clean..!
So, what is the best way to get rid of every little python thingy and what are the best packages/methods for reinstalling Python27, QGIS and PyCharm? Should I go for osgeo or not, should I first install Pycharm or Python etc. Hopefully you have some good thoughts and tools on this. I'm a fan of pip, so in the end I hope its possible just to use pip for installing the packages all around.
I'm working on Windows 7, 64bit (thanks for the headsup Karel)
Go to add/remove programs in windows and uninstall everything. Then reinstall everything. Do your Python install first and PyCharm should detect everything. I'd suggest doing the 32 bit Python install as some packages aren't compiled for 64 bit and it makes things a bit challenging to find and install them.
Pip is standard in the python install now. You'll see a check box in the installer for it, which is pre-checked. I'd change your install directory to something simple like C:\Python27
Other than that it should be pretty straightforward. However I doubt you really need to uninstall Python. You can just go to settings and under the interpreter section add the C:\Python27 directory. PyCharm is constantly scanning for installed modules, so it will know in real time that you've installed them. You can even install packaged via PIP while PyCharm is open and within second PyCharm will recognize it as a valid package.
If you're missing packages you can also import them in PyCharm and when you get the red underline saying it's missing, hover your mouse over it and hit alt+enter and you'll get a menu to install it.
Related
Trying to install new packages via pip on Windows, but after it installs - Python cannot resolve the import. For Example, I have just installed the Python package similaritymeasures and pip correctly installed it, but when I import it into my Python program, it cannot find the import. Has anyone know a way around this?
Make sure that you restart VSCode after downloading your package. Sometimes, when you download a package while VSCode is still running, it doesn't recognize the package when using import similaritymeasures.
If that didn't work, then make sure that VSCode is using your preferred version of python. It is possible that you have more than one python version and it's using a non-compatible one to run your code. This can be done at the bottom right corner of the window by clicking the box that says: (for example) 3.9.5 64-bit. Then select a different (preferably older) version from the pop up widnow.
These are the solutions that came to my mind, I hope this helped.
I am installing python on windows10 and trying to install the opencv and numpy extentions in the command window. I get no error installing them and it says it is successfully installed. But when I try to check the installation and import cv2 it does not recognize it and give me the error: no module named cv2.
can anybody help me with this problem? Is there something wrong in installation process or do I need to install something else?
I checked the newest version of each and used the compatible one with my system.
Thanks.
One solution could be that you have 2 versions of python. So, go to the specific python's scripts directory and run: pip install numpy
If that too doesn't work, you can find the answers to this question on Why can't I import opencv3 even though the package is installed?, as stated by #Cut7er.
I have tried the solutions given to the above stated question myself also. But, they didn't work for me. So, another thing that you could try to use is this IDE called PyCharm. It ofcourse is much more beautiful that the IDLE, but it also has an inbuilt GUI controlled installation of binaries or packages. That would make things a lot easier. I have faced a lot of issues with packages for python and this IDE made things a lot easier. You can find it on https://www.jetbrains.com/pycharm/download/#section=windows.
You can also use anaconda. But, I found it a little difficult to use since, it has similar issues.
EDIT:
Seems like you are using PyCharm. But, you are installing libraries from your command prompt. So, see the answer to: ImportError: No module named 'bottle' - PyCharm. This answer guides you through how to install a certain library through your PyCharm window itself. So,
1) Go to Files>Settings
2) Search for "Interpreter" from the searching tab. Open the interpreter
3) You can now see a plus sign on the right. A click on it will open up a section on the left.
4) In the searching tab, search for numpy or opencv. Click on whichever module you want to install. And then click on the "install package" button on the bottom left. This will install the package for you.
5) Then click save. And run your file that says import cv/cv2.
This should probably do the trick.
Hope it helps!
Is it possible that you have 2 versions of python on your machine and your native pip is pointing to the other one? (e.g. you pip install opencv which installs opencv for python 2, but you are using python 3). If this is so, then use pip3 install opencv
I removed the Anaconda version on my machine, so I just have python 3.7 installed. I removed the python interpreter(Pycharm) and installed it again and the problem got fixed somehow!
I suspect you have two versions of python and the one you're using doesn't have opencv on it, because pip pointed to the wrong one.
A pragmatic solution assuming you're using the python version with conda is to just use conda to install cv2:
conda install -c menpo opencv
A more careful solution is to figure out how to get the pip that points to the python version you're using. On linux I can check that my pip points to my python like this:
:~$ which python
/home/kpierce/anaconda3/bin/python
:~$ which pip
/home/kpierce/anaconda3/bin/pip
So you see the pip and python versions are associated. On windows I suspect you do an analogous thing on the command line like
where python
where pip
And if they don't match, you might try
where python
where pip3
to see if those match. You need to use the pip that points to the correct python version. You can view the python version by entering the python interpreter and running
import sys
sys.version
Alright, I need some pointers. I am missing something. I am trying to use Pillow through Python 3.6. The platform I use is Visual Studio 2017. I can't get it to work.
I downloaded Pillow from this website:
https://pypi.org/project/Pillow/
And ran the installer.
According to my research, I need pip to install it; which comes built-in python 3.6. I have seen sign that it is actually installed through my module in visual studio (pip 9.0.3). I simply need to use the following line:
from pip.commands import install
and also tried
import pip
Now, according to this:
https://pillow.readthedocs.io/en/5.2.x/installation.html
All I have to do is
pip install Pillow
Though other sites indicate that PIL is still being used. I have tried both without success. Pillow is not recognized and a error comes in: invalid syntax.
I am clearly doing something wrong. I consulted some youtube tutorial; they all skip that part. They download then go straight to their coding platform and it works.
I can only guess I have additional steps to do with Visual Studio.
Also... The location of my files might be out of whack due to IT security on my work laptop. Could that be an issue?
You can do the following:
python -m pip install pillow
No need to downloade Pillow from the website.
After that, to use it you can do:
import PIL
Thanks for the feedback. I played with Visual Studio some more; there is a way of getting it straight from the menu.
I opened a Python 3.6 project/solution. On the "Python Environment" node in the solution explorer, I right clicked and created a virtual Python environment.
Then I right clicked on the virtual environment and selected "Install Python Package...".
You can then search the package you need for your project.
I don't know if this is the most efficient way. From my research, I think the package are only applicable to my virtual environment; I still have to test that out to make sure.
I may have gone the long way around, but writing the proposed code did not work out. I am sure it works, but I am thinking I might not be using it in the right location.
Anyway, thanks for the help!
So after numerous attempts at installing NumPy, all seem to have gone well until I boot up PyCharm and import numpy. It throws the "Module not found" error with just a single line of code, being:
import numpy as numpy
It's getting fairly frustrating, after installing numpy through pip, downloading the .whl and manually installing it, and even somehow bricking my computer by repairing python 3.6. I've got no idea as to what I'm doing wrong. Help would be greatly appreciated.
Without knowing exactly what you have installed in your computer, it can be a bit tricky to troubleshoot it. However, you have to be aware that you can have multiple Python installations in your computer. It is quite common to have Python2.X and Python3.X side by side.
When you used pip to install numpy, you installed it for a specific Python interpreter (sometimes you have pip2 and pip3 in your system, for example). And then, when you use PyCharm, it may be grabbing the wrong Python interpreter. You can go to File/Settings/Project and you will find something like the window below:
You will see that you can choose your interpreter and it will give you the list of all installed packages. I suggest that you check that you have numpy listed.
Moreover, from the same window you can install the packages you need; just click on the green + sign at the right of the screen and search for numpy and follow the needed steps.
Pro Tip: You should definitely consider using virtual environments, which are entirely supported by PyCharm.
I'm trying to install a Python Module by running a Windows installer (an EXE file).
The Problem is that the default python folder and the defualt Installation Library are set To disc D:\ and are grayed out (meaning I can't change it). It might be fine is some places, but in my computer, D is the DVD drive, meaning that no installation is possible.
Is there any way to change this or to overcome this?
It's not "default folder", and there's a reason there's "found in registry" next to the version. You need to re-register the Python installation if you've moved it, either by installing it again (without removing) in the same folder, or changing the directory saved in registry (HKCU\Software\Python\PythonCore\X.X\InstallPath, possibly on Wow3264Node) either manually or using registration script.
Because what you're installing (you don't say what it is) seems to be standard distutils-generated installer (as Cat Plus Plus points out in his comment) you don't have to install it by running installer. You can install it using easy_install program what allows you to choose which Python to use. See my answer to Can I install Python windows packages into virtualenvs? question.
EDIT
Now I see in your comment you're installing setuptools. This complicates things a little bit as this is the package which contains easy_install tool I mentioned above. You have chicken/egg problem here... There's solution for this, however. You can use ez_setup script to install setuptools without using exe installer.