News from this site

 Rental advertising space, please contact the webmaster if you need cooperation


+focus
focused

classification  

no classification

tag  

no tag

date  

no datas

Cartopy installation nanny tutorial--three days of trial and error, finally succeeded

posted on 2023-05-07 18:50     read(819)     comment(0)     like(1)     collect(5)


It's the first part that matters, the rest doesn't matter

Cartopy installation nanny tutorial – three days of trial and error, finally succeeded

cartopy installation process

At the beginning, I used pip install cartopy to follow cartopy, but it couldn't be installed. It may not be a pip problem.

Then I went to Baidu. I read the article and said that it was because some official things did not match. I needed to download some packages and install them locally. Then I read a lot of articles. The online posts were all python3.8 or 3.9, but I installed python3.7, and I think this should not be a big problem (later I will know that I was wrong and wasted a lot of time, 555~). The corresponding files are downloaded here Archived: Python Extension Packages for Windows - Christoph Gohlke (uci.edu)

Then I started to follow the cat and draw the tiger. The following is the local file whl I downloaded :

Please add a picture description
Remember to install cartopy last, as cartopy depends on other packages.

In the end, it was indeed installed, but there is a big problem, and an error will be reported as soon as it is called, which is the most uncomfortable here. . . .

As soon as I call cartopy it says I'm missing a module.

Please add a picture description

I thought that the downloaded package was incorrect, so I uninstalled the installed packages one by one with pip uninstall, downloaded and reinstalled again, and repeated it several times, but the same result - missing modules, during which I also reinstalled Some other dependent packages, but have no effect.

I am really reluctant to change the python version, because many things need to be changed after changing python, and those installed libraries have to be re-downloaded for a long time, and the used compiler, jupyter needs to change the kernel and replace it with a new python.

After a few days of stalemate, I decided to try the installed python version again. I chose a version of python3.8, which was also installed locally.

Here I discovered the New World. It turns out that multiple python versions can be downloaded at the same time, but the required environment variables are modified as follows, so that one computer can switch between multiple python versions. It’s so cool. I’m Xiaobai. I found this right I'm rarely happy.

Note: The corresponding python version downloads the corresponding version of the library

Almost the same steps as above, here is my downloaded version:

Please add a picture description

After the installation, import cartopy finally no longer reports an error, I am ecstatic. It turned out to be really a python version issue.

As a result, when I was using it, I poured cold water on it again, and some attribute did not exist.

I thought python3.8 would not work, and later downloaded a python3.9

Reinstall the above steps to install again, the following is the package I downloaded with python3.9:

Please add a picture description

The result is the same as python3.8. I realized that this error has nothing to do with the python version, and then I followed the prompts to find the source code of the few lines that reported the error. Since this error is in a class, I can’t tell which variable’s attribute it is, and then I read along the code, and finally I found that this error is an attribute of matploylib.axes.Axes:

    other = (self.ignore_existing_data_limits,
             self._autoscaleXon(), self._autoscaleYon())

The source code seems to come from this, but I can't remember clearly.

So I searched for this feature from Baidu, but I couldn't find this attribute. I realized that this attribute might be written wrong, so I boldly modified the source code. I saw it on Baidu. One of the attributes is similar to the error attribute of this source code. I first modify the error code to this,

        other = (self.ignore_existing_data_limits,
                 self.set_autoscalex_on(), self.set_autoscaley_on())

Although the error is reported, the error has changed and becomes the next few lines of it, but I am sure of one thing, it is definitely that this position is incorrect. So I saw that there is another attribute similar to this, so I tried the following:

        other = (self.ignore_existing_data_limits,
                 self.get_autoscalex_on(), self.get_autoscaley_on())

It turned out to be a success. I can execute my code smoothly.

After groping, it is actually very simple to do wrong, just replace the version of python3.7. Modify the source code again, and it will be ok.

The computer switches the version of python, which is to call python in cmd

Then record how to switch between multiple versions of python, and download different versions of python to different folders:

Right-click This PC, click Properties:

Please add a picture description

Click System Protection:

Please add a picture description

Select Advanced, and then click Environment Variables:

Please add a picture description

Find the path and click in:

Please add a picture description

Then modify it again:
Please add a picture description

Just replace the one I circled with the folder where the python version you want to use is located. There must be a Scripts folder under that folder. If you can’t find it, find the path of the folder where python.exe is located. . I forgot to circle it in front of D:\, sorry. Replace all with the path of the python you want to use.

Switch jupyter's python kernel

About changing the kernel of jupyter

jupyter kernelspec list

This command can find the file of the jupyter kernel, and finally find the file of kernel.json and modify the path of python.exe inside.

Please add a picture description

pycharm switch kernel

File->Settings->Project->Python Interpreter->Settings Icon->Add

You can modify it in it



Category of website: technical article > Blog

Author:python98k

link:http://www.pythonblackhole.com/blog/article/299/fa59f79fdcdebee33b13/

source:python black hole net

Please indicate the source for any form of reprinting. If any infringement is discovered, it will be held legally responsible.

1 0
collect article
collected

Comment content: (supports up to 255 characters)