E:\anaconda\python.exe C:/Users/lenovo/PycharmProjects/pythonProject4/17.py {'光明': 41, '南山': 127, '宝安': 59, '布吉': 57, '盐田': 66, '福田': 109, '罗湖': 85, '龙华': 61, '龙岗': 51} Traceback (most recent call last): File "C:\Users\lenovo\PycharmProjects\pythonProject4\17.py", line 18, in <module> squarify.plot(sizes=sizes,label=label, edgecolor='white', linewidth=3) File "E:\anaconda\lib\site-packages\squarify\__init__.py", line 241, in plot normed = normalize_sizes(sizes, norm_x, norm_y) File "E:\anaconda\lib\site-packages\squarify\__init__.py", line 170, in normalize_sizes total_size = sum(sizes) TypeError: unsupported operand type(s) for +: 'int' and 'str'
时间: 2024-04-08 13:30:56 浏览: 18
根据错误信息,问题出在对数据进行求和的地方。具体来说,`TypeError: unsupported operand type(s) for +: 'int' and 'str'` 表示无法将整数和字符串相加。
根据你提供的代码,可能的原因是 `sizes` 字典中的值是字符串类型,而 `squarify.plot()` 函数要求值为数值类型。请确保 `sizes` 字典中的值为数值类型。
你可以尝试将 `sizes` 字典的值转换为整数类型,例如:
```python
sizes = {key: int(value) for key, value in sizes.items()}
```
在这之后,再运行代码看看是否还会出现同样的错误。如果问题仍然存在,请检查一下 `data` 数据框中的 `unit_price` 列是否包含了非数值类型的数据。
相关问题
E:\Anaconda\python.exe C:\Users\86137\PycharmProjects\pythonProject\main.py
根据你的描述,问题出现在运行命令"E:\Anaconda\python.exe C:\Users\86137\PycharmProjects\pythonProject\main.py"时。你遇到了"Fatal error in launcher: Unable to create process using '“E:\Anaconda\python.exe”"的报错信息。这个错误通常是由于安装的Anaconda与Python路径发生了变化导致的。
为了解决这个问题,你可以尝试以下几种方法:
1. 确保你已经正确安装了Anaconda,并且确保Anaconda的路径和Python的路径设置正确。
2. 如果你之前安装了旧版本的Python,你可以尝试卸载旧版本的Python,并重新安装最新版本的Anaconda。这样可以确保Anaconda和Python的路径都是正确的。
3. 如果你的Python路径已经更改,你需要在Pycharm中进行相应的更改。你可以关闭当前项目,新建一个项目,并在新项目中指定正确的Python路径。或者,你也可以在当前项目中进行修改,将Python路径指向正确的位置。
4. 确保你正确执行了运行命令。对于你提供的命令,需要注意文件路径的正确性和命令的正确格式。你可以按照下面的示例运行命令:"python3 main.py inputFileLocation",其中"inputFileLocation"需要替换为你实际的文件路径。
希望以上方法可以帮助你解决问题。如果问题仍然存在,请提供更多详细信息,以便我可以更好地帮助你解决。<span class="em">1</span><span class="em">2</span><span class="em">3</span><span class="em">4</span>
PackagesNotFoundError: The following packages are not available from current channels: - //mirrors.aliyun.com/pypi/simple/ Current channels: - https://conda.anaconda.org/anaconda/win-64 - https://conda.anaconda.org/anaconda/noarch - https://repo.anaconda.com/pkgs/main/win-64 - https://repo.anaconda.com/pkgs/main/noarch - https://repo.anaconda.com/pkgs/r/win-64 - https://repo.anaconda.com/pkgs/r/noarch - https://repo.anaconda.com/pkgs/msys2/win-64 - https://repo.anaconda.com/pkgs/msys2/noarch To search for alternate channels that may provide the conda package you're looking for, navigate to https://anaconda.org and use the search bar at the top of the page.
这个错误提示说明您正在尝试从未知的conda channel中下载安装包,而该channel并不包含您需要的安装包。您可以尝试以下几个解决方案:
1. 确认您所需的包名是否正确,以及您的网络连接是否正常。
2. 尝试将conda的channel更换为默认的channel,使用以下命令:
```
conda config --remove-key channels
```
3. 尝试将conda的channel更改为清华或者中科大的镜像,使用以下命令:
清华镜像:
```
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes
```
中科大镜像:
```
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
```
4. 如果以上方法都无法解决问题,可以尝试直接从PyPI上安装Basemap库,使用以下命令:
```
pip install basemap
```
或者:
```
pip3 install basemap
```
需要注意的是,如果您使用的是Python 3,则需要使用pip3命令来安装。同样,如果您使用的是Windows并且使用的是Anaconda环境,则需要使用以下命令安装Basemap库:
```
conda install -c conda-forge basemap
```
希望这些方法可以帮助您解决问题。
相关推荐
![gz](https://img-home.csdnimg.cn/images/20210720083447.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)