我经历过各种Stack Overflow问题,但没有答案为我解决了这个问题。 我可能没有看到一条“东西”。
已经安装了pandas
,它说在那里,但是numpy
将导入而pandas
将不会导入。
有什么想法吗?我想念什么?
如果我输入:
!pip3 install pandas
我得到:
Requirement already satisfied: pandas in c:\users\ron mcmillan\appdata\local\programs\python\python38\lib\site-packages (1.0.3)
Requirement already satisfied: pytz>=2017.2 in c:\users\ron mcmillan\appdata\local\programs\python\python38\lib\site-packages (from pandas) (2020.1)
Requirement already satisfied: numpy>=1.13.3 in c:\users\ron mcmillan\appdata\local\programs\python\python38\lib\site-packages (from pandas) (1.18.4)
Requirement already satisfied: python-dateutil>=2.6.1 in c:\users\ron mcmillan\appdata\local\programs\python\python38\lib\site-packages (from pandas) (2.8.1)
Requirement already satisfied: six>=1.5 in c:\users\ron mcmillan\appdata\local\programs\python\python38\lib\site-packages (from python-dateutil>=2.6.1->pandas) (1.14.0)
答案 0 :(得分:0)
确保正在运行jupyter的python安装是具有pandas的安装。运行where jupyter
(在linux / mac上为which
),并确保它与上面的路径匹配。另外,尝试使用where pip
确保pip
,python
和jupyter
的安装匹配。
为确保您使用的是特定版本的python + pip来安装软件包,可以调用pip模块而不是脚本,例如与c:\users\ron mcmillan\appdata\local\programs\python\python38\python -m pip install [pkg]
我会考虑使用virtualenv或conda之类的环境管理器来简化环境和安装。
答案 1 :(得分:0)
尝试一下:
library(stringr)
test_data <- data.frame(coef=c(1.109,1.296,1.363),
low=c(1.041,1.206,1.274),
high=c(1.182,1.393,1.458),
boxsize=c(0.1, 0.1, 0.1))
column1 = c("Variable", "N_Quartile 1", "N_Quartile 2", "N_Quartile 3")
column2 = cbind(c("HR", test_data$coef),
c("CI -95%", test_data$low),
c("CI +95%", test_data$high))
L = max(nchar(column2))
padded_text =apply(column2,1,
function(i)paste(str_pad(i,L),collapse=" "))
test_data <- rbind(NA, test_data)
pdf("test.pdf",width=8,height=4)
forestplot(
labeltext =cbind(column1,padded_text),
mean = test_data$coef, upper = test_data$high,
lower = test_data$low,
txt_gp=fpTxtGp(cex=0.8),align="c",
is.summary=c(TRUE, FALSE, FALSE, FALSE),
boxsize = test_data$boxsize,lwd.ci=3,
graphwidth=unit(100,'mm'))
dev.off()
有一个冗长的解释here。
答案 2 :(得分:0)
仔细阅读以上冗长的说明-需要再次进行解释。
import sys
!{sys.executable} -m pip install numpy
返回:
'c:\users\ron' is not recognized as an internal or external command,
operable program or batch file.
import sys
sys.path
返回:
['C:\\Users\\Ron McMillan',
'c:\\users\\ron mcmillan\\appdata\\local\\programs\\python\\python38-
32\\python38.zip',
'c:\\users\\ron mcmillan\\appdata\\local\\programs\\python\\python38-32\\DLLs',
'c:\\users\\ron mcmillan\\appdata\\local\\programs\\python\\python38-32\\lib',
'c:\\users\\ron mcmillan\\appdata\\local\\programs\\python\\python38-32',
'',
'c:\\users\\ron mcmillan\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages',
'c:\\users\\ron mcmillan\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\win32',
'c:\\users\\ron mcmillan\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\win32\\lib',
'c:\\users\\ron mcmillan\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\Pythonwin',
'c:\\users\\ron mcmillan\\appdata\\local\\programs\\python\\python38-32\\lib\\site-packages\\IPython\\extensions',
'C:\\Users\\Ron McMillan\\.ipython']
!输入python
返回
系统找不到指定的文件。
在命令提示符下:
朱庇特
C:\users\ron mcmillan\appdata\local\programs\python\python38-32\Scripts\jupyter.exe
和
where pip
C:\users\ron mcmillan\appdata\local\programs\python\python38\Scripts\pip.exe
C:\users\ron mcmillan\appdata\local\programs\python\python38-32\Scripts\pip.exe
C:\users\ron mcmillan\appdata\local\Microsoft\WindowsApps\pip.exe
那么,Jupyter注意到找到了Python吗?
答案 3 :(得分:0)
好的,我要给出一个全新的,有根据的答案。
您似乎至少已经安装了两个Python安装程序,一个安装在..python\python38
中,一个安装在..\python\python38-32
中。 pandas
安装在第一个上,而jupyter
安装在第二个上。您每个人都有一个pip
的版本,以及Microsoft\WindowsApps
中的第三个版本。
在Windows上,仅卸载计算机上所有版本的Python可能是安全的。然后下载Miniconda for Windows。像pip
一样,Miniconda是Python的软件包管理器;但是与pip不同,它还可以安装非Python文件,这使各种事情变得更加容易。称为“ Miniconda”以区别于“ conda
”和“数据科学家可能需要的几乎所有软件包”的“ Anaconda”-Miniconda只是为您提供了软件包管理器conda
,然后您可以选择安装您真正想要的东西。
一旦安装了conda
,请创建一个新的conda环境(conda create -n MYNEWENV
-如果您有20分钟,那么请read the quickstart explanation),然后尝试使用conda install...
下载所有内容< / p>
您可以指定从哪个“渠道”下载软件包,但可能不需要。只需尝试conda install jupyter numpy pandas
;或在the Conda cloud中搜索所需内容。
答案 4 :(得分:0)
好的,谢谢。
是的,我知道那是一团糟-直到我不明白为止。图片很有意义。